Revisiting Decimal (was: Prioritized list of Decimal method additions)

Sam Ruby rubys at intertwingly.net
Wed Dec 3 13:04:43 PST 2008


I saw the meeting minutes, and got a debrief from Allen yesterday.
I'm still unclear on how to proceed with Decimal, even if the new
target is Harmony.

Waldemar's issues were raised and responded to prior to Kona:

https://mail.mozilla.org/pipermail/es-discuss/2008-November/008074.html

Quick summary: there are at least eight sections with typos and
transcription errors.  By transcription errors, I mean places where
the prose doesn't match the output of the code that I posted
previously.  Those are embarrassing, but at this point moot.  Pratap
has already excised Decimal from the spec.

What are we left with relative to the the following output from the
code that I wrote?

http://intertwingly.net/stories/2008/09/20/estest.html

Relative to that output, I've heard two issues.

The first was "no user visible cohorts".  The issue is Waldemar's
insistence that ES is irretrievably broken if array lookup for
x[1.10m] respects the trailing zero.  IIRC, Brendan's position was a
more pragmatic one, namely that "small" integers (like, say, up to
10**20th) are the only values for which toString must avoid both
exponential notation and trailing zeros, other values shouldn't get in
the way of "doing the right thing".  That would have been fine, but
unfortunately he couldn't make the meeting (something I definitely
understand).  Mike and I weren't then, and still aren't happy about
conceding to Waldemar's position on this one, but at Redmond we did
with the understanding that with that concession, Decimal was "in".

The second was the duplication between "Math.min" and "Decimal.min".
I was operating under the "if it ain't broken, don't fix it"
guidelines.  To date, Math.min *always* returns a Number, never an
Object.  Waldemar apparently feels that people will call the wrong
function.  To me, this is a "you say N-EEE-THER, I say N-EYE-THER"
issue.  If the consensus is that Math.min should be changed and
Decimal.min should be removed, that's a pretty quick fix.

So now the question is: where are we now?

- Sam Ruby

On Sat, Sep 20, 2008 at 8:57 PM, Sam Ruby <rubys at intertwingly.net> wrote:
> Sam Ruby wrote:
>> Previous discussions focused on operators and type/membership related
>> builtin functions (i.e., typeof and instanceof).  Here's a prioritized
>> list of functions provided by IEEE 754-2008 and/or the decNumber
>> implementation.
>>
>> The actual number of "a" and "a-" methods is fairly small, particularly
>> once you remove ones that are available in ECMAScript via other means.
>
> Updated test results including these methods can be found here:
>
> http://intertwingly.net/stories/2008/09/20/estest.html
>
> - Sam Ruby
>
>> - - - - -
>>
>> Absolute requirement, and must be implemented as an 'instance' method
>> (for most of the others, the difference between a 'static' and
>> 'instance' method is negotiable):
>>
>>  >  *  a    toString
>>
>> Available as prefix or infix operators, or as builtin functions, may not
>> need to be duplicated as named Decimal methods:
>>  >  *  a    add
>>  >  *  a    compare
>>  >  *  a    copy
>>  >  *  a    copyNegate
>>  >  *  a    divide
>>  >  *  a    isFinite
>>  >  *  a    isNaN
>>  >  *  a    multiply
>>  >  *  a    remainder
>>  >  *  a    subtract
>>
>> Essential 754, not available as infix operator, so must be made
>> available as a named method.  For consistency with Math, abs, max,
>> and min should be 'static' methods:
>>
>>  >  *  a    quantize
>>  >  *  a    copyAbs        [called abs]
>>  >  *  a    max
>>  >  *  a    min
>>
>> Very useful functions which are not in 754 for various reasons;
>> strongly recommend include:
>>
>>  >  *  a-   divideInteger  [extremely handy]
>>  >  *  a-   digits         [= significant digits]
>>  >  *  a-   reduce         [often asked for]
>>  >  *  a-   toEngString    [really handy in practice]
>>  >  *  a-   getExponent    [esp. if no compareTotal]
>>
>> Other 754 operations that are less essential but would probably add
>> later anyway.  'b+' are a subset that are especially useful in
>> practice:
>>
>>  >  *   b   FMA
>>  >  *   b   canonical
>>  >  *   b   compareSignal
>>  >  *   b+  compareTotal
>>  >  *   b   compareTotalMag
>>  >  *   b   copySign
>>  >  *   b   isCanonical
>>  >  *   b+  isInfinite
>>  >  *   b+  isInteger
>>  >  *   b   isNormal
>>  >  *   b+  isSignaling             [if sNaNs supported]
>>  >  *   b+  isSignalling            [" " "]
>>  >  *   b+  isSigned
>>  >  *   b   isSubnormal
>>  >  *   b+  isZero
>>  >  *   b   logB
>>  >  *   b   maxMag
>>  >  *   b   minMag
>>  >  *   b   nextMinus
>>  >  *   b   nextPlus
>>  >  *   b   radix
>>  >  *   b   remainderNear
>>  >  *   b+  sameQuantum
>>  >  *   b   scaleB
>>  >  *   b+  setExponent
>>  >  *   b   toInt32
>>  >  *   b   toInt32Exact
>>  >  *   b+  toIntegralExact         [perhaps only one of these]
>>  >  *   b+  toIntegralValue         [" " " " "]
>>  >  *   b   toUInt32
>>  >  *   b   toUInt32Exact
>>
>> Probably drop because conflict with ES bitwise logical ops:
>>
>>  >  *    c  and (as digitAnd)
>>  >  *    c  invert (as digitInvert)
>>  >  *    c  or (as digitOr)
>>  >  *    c  rotate
>>  >  *    c  shift
>>  >  *    c  xor (as digitXor)
>>
>> And, finally, not needed:
>>
>> (The first two of these are 754 but don't fit with ES)
>>  >  *     class
>>  >  *     classString
>>  >  *     fromBCD
>>  >  *     fromInt32
>>  >  *     fromNumber
>>  >  *     fromPacked
>>  >  *     fromPackedChecked
>>  >  *     fromString
>>  >  *     fromUInt32
>>  >  *     fromWide
>>  >  *     getCoefficient
>>  >  *     setCoefficient
>>  >  *   d nextToward
>>  >  *     show
>>  >  *     toBCD
>>  >  *     toNumber
>>  >  *     toPacked
>>  >  *     toWider
>>  >  *     version
>>  >  *     zero
>>
>> - Sam Ruby
>>
>> _______________________________________________
>> Es-discuss mailing list
>> Es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>
> _______________________________________________
> Es-discuss mailing list
> Es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss


More information about the Es-discuss mailing list