Prioritized list of Decimal method additions

Sam Ruby rubys at intertwingly.net
Sat Sep 20 18:57:13 PDT 2008


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
> 
> 




More information about the Es-discuss mailing list