ES Decimal Status

Garrett Smith dhtmlkitchen at gmail.com
Wed Sep 24 14:17:19 PDT 2008


2008/9/24 Maciej Stachowiak <mjs at apple.com>:
>
> On Sep 24, 2008, at 8:41 AM, Michael wrote:
>
> Maciej wrote:
>
> "I'm not sure what you are getting at. a[1] and a[1.000] refer to the
>
> same property in ECMAScript, but a[1m] and a[1.000m] would not. Are
> you saying this isn't a problem?"
>
> This is not quite true as you can see here:
>
> var a = [];
> a[1] = "foo";
> a[1.00] = "bar";
>
> WScript.Echo("length: "+a.length + "\n["+ a.join()+"]")
> --------------------------------------------
> length: 2
> [,bar]
>
> Firefox (3.0.2) does the same
>
> It seems to me that your test case proves that 1 and 1.00 refer to the same
> property, as I described. (The reason the array is length 2 is that there is
> an implicit unset 0 property.)

The reason a.length is 2 is because of the way [[Put]] works on Array.

If ToUint32(P) is >= the value of the Array's length property, the
length property gets set to ToUnit32(P) + 1.

There's no "implicit unset 0 property".

This is just a diversion from the real issue, which (if I understand
right) is how decimals get converted -- what
Decimal.prototype.toString does.

 Garrett

> Regards,
> Maciej


More information about the Es-discuss mailing list