Thoughts on IEEE P754

Sam Ruby rubys at intertwingly.net
Fri Aug 22 15:56:02 PDT 2008


Oops, forgot to copy the list

On Fri, Aug 22, 2008 at 6:54 PM, Sam Ruby <rubys at intertwingly.net> wrote:
> On Fri, Aug 22, 2008 at 6:02 PM, Waldemar Horwat <waldemar at google.com> wrote:
>> Sam Ruby wrote:
>>> 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.
>>
>> Now we've gone full circle without actually answering the question I asked:  What should the full result of converting 1.1 to a Decimal be in ECMAScript?
>>
>> "An error" or "you can't do it" is not a valid answer because it violates IEEE P754.
>
> I'm clearly not following something.
>
> I'm suggesting that there not be any implicit conversions from
> binary64 to decimal128.  I've made a suggestion as to what
> Decimal.parse should do.  If there are no other means to do a
> conversion, that I can't answer the question about what such a
> non-existent method might do.
>
> If you suggest that we need to do implicit conversions, I am aware of
> a few different mechanisms to do so.  I think that the one that
> produces the most expected results would be based on
> decimal128-convertFromDecimalCharacter.
>
> If we want to provide more explicit conversions, then such named
> methods should match the definition in IEEE P754.
>
> I don't know how to more fully answer the question.
>
>>    Waldemar
>> _______________________________________________
>> Es-discuss mailing list
>> Es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>
> - Sam Ruby
>


More information about the Es-discuss mailing list