Thoughts on IEEE P754
MFC at uk.ibm.com
Fri Aug 22 08:37:54 PDT 2008
> >> var a = ;
> >> a = "first";
> >> a[0.0m] = "second"; // a second property?
> >> a[0.000m] = "third"; // a third?
> > [...]
> > It seems to me that if trailing zeros are retained in a call to
> > ToString, then to be consistent with ES3, the three assignments above
> > would produce three properties. And if trailing zeros are lost, you
> > would expect to only have one. Both approaches are internally
> > consistent, and it surprises me to see either one characterized as
> > "breaking" array lookup.
> Well, the intuition is that two equal numbers should index the same
> property. This is an invariant in ES3 and it makes a lot of sense.
Seems to me the problem here is not decimal (or binary) representations
but arrays (consider a(0.0) and a("0.0")).
In effect the array definition in ES3 says -- in a rather roundabout way
-- that all indexes must be an integer (which fits in 32 bits if encoded
in binary). So, as long as there's a toInt32 in there, decimals with
trailing zeros after the point are just fine. In other words the
processing of array indexes could (conceptually) be
toString->toNumber->toInt32 (or something like that).
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU
More information about the Es-discuss