Thoughts on IEEE P754

Jason Orendorff jason.orendorff at gmail.com
Thu Aug 21 23:30:29 PDT 2008


On Thu, Aug 21, 2008 at 9:08 PM, Sam Ruby <rubys at intertwingly.net> wrote:
> Waldemar Horwat wrote:
>> - We should not print the trailing zeroes.  IEEE P754 does not
>> require it, and it breaks things such as array lookup.  There is
>> precedence for this in ECMAScript:  -0 and +0 both print as "0".  If
>> someone really wants to distinguish among equal numbers, he can do it
>> with a function call to one of the mandated functions.
>
> Please explain the breakage?

In ES3, an expression like a[b] calculates ToObject(a) and
ToString(b), then performs the property lookup. Thus arr[0] and
arr["0"] are identical in meaning.

  http://bclary.com/2004/11/07/#a-11.2.1

Assuming we retain this rule and add decimal numbers, a question
arises as to how this code should behave:

  var a = [];
  a[0] = "first";
  a[0.0m] = "second";   // a second property?
  a[0.000m] = "third";   // a third?

The question applies to all objects, not just Arrays.

I think this is a tricky question; neither answer is obviously right to me.

-j


More information about the Es-discuss mailing list