Thoughts on IEEE P754

Waldemar Horwat waldemar at
Fri Aug 22 11:45:10 PDT 2008

David-Sarah Hopwood wrote:
> Jason Orendorff wrote:
>> On Fri, Aug 22, 2008 at 6:22 AM, Sam Ruby <rubys at> wrote:
>>> On Fri, Aug 22, 2008 at 2:30 AM, Jason Orendorff
>>> <jason.orendorff at> wrote:
>>>>  var a = [];
>>>>  a[0] = "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.
> Two values that are === should index the same property [*]. Two values that
> are == do not, in general.
> So, it would be possible to make === take into account trailing zeroes,
> while == ignores them. Given that the trailing zeroes are supposed to be
> semantically significant ("scale preservation"), there's a strong case
> for saying that values that differ only by trailing zeroes should be
> distinguishable -- and if not by ===, then how?

ES3 already addresses this.  Binary floating-point already has a cohort of equal values:  {-0, +0}.  They are considered === to each other.  The same should apply to cohorts of equal decimal values.  Anything else would be madness; you'd say that -0m === +0m, but 1e10m - 1e10m !== 0m.


More information about the Es-discuss mailing list