Thoughts on IEEE P754

Sam Ruby rubys at intertwingly.net
Fri Aug 22 14:51:22 PDT 2008


On Fri, Aug 22, 2008 at 5:06 PM, Waldemar Horwat <waldemar at google.com> wrote:
> Sam Ruby wrote:
>> On Fri, Aug 22, 2008 at 4:18 PM, Waldemar Horwat <waldemar at google.com> wrote:
>>> Sam Ruby wrote:
>>>> On Fri, Aug 22, 2008 at 3:55 PM, Waldemar Horwat <waldemar at google.com> wrote:
>>>>> Here's a question for you:
>>>>>
>>>>> What should the full result of converting 1.1 to a Decimal be in ECMAScript?  Describe the precise answer and justify your choice of answer.  Hint:  This would behave remarkably differently depending on whether we settle on Decimal64 or Decimal128.
>>>> At the present time, I am only suggesting that ECMAScript support
>>>> Decimal128, and that there not by *any* implicit conversions to
>>>> Decimal.
>>>>
>>>> Decimal.parse(n) would take n.ToString() and then parse that as a
>>>> Decimal128 value.  If (in the future) additional precisions were
>>>> allowed by the standard, then there would be a second parameter on
>>>> Decimal.parse that would allow the precision to be specified.
>>>> Meanwhile:
>>>>
>>>> true: Decimal.parse(1.1) == 1.1m
>>> An interesting choice.  This produces more sensible results but directly violates IEEE P754 section 5.3.3.
>>
>> I'm looking at DRAFT P754, April 24, 2008.  Section 5.3.3 in this
>> draft is entitled "logBFormat operations".  I doubt that's what you
>> are referring to.  Can you provide me with a bit more context?
>
> Sorry, I meant 5.4.2.

I still don't see the conflict.  If we desire, we can provide multiple
mechanisms for converting binary64 floating point numbers to
decimal128 floating point numbers.  At a minimum, we should provide an
analog to ES's existing parseFloat.  I'd suggest that it be named
Decimal.parse instead, and that it make use of
decimal128-convertFromDecimalCharacter.

>>> If we're using Decimal64, then there are no major issues.  Converting 1.1 do decimal would produce 1.1m, as both you and I desire.
>>>
>>> If we're using Decimal128, then IEEE P754 mandates that binary floats be convertible to decimal floats and that the result of the conversion of 1.1 to decimal be 1.100000000000000088817841970012523m.
>>>
>>> Hence, a dilemma if we choose Decimal128.  Do we obey the standard?
>>
>> Deviations from the standard merit bug reports.
>
> Are you saying this is a bug in IEEE P754?  I doubt it.

I guess I was unclear.  Places where draft ES3.1 deviate from IEEE
P754 merits bug reports -- on ES3.1.

>    Waldemar
> _______________________________________________
> Es-discuss mailing list
> Es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>


More information about the Es-discuss mailing list