Consistent decimal semantics

Sam Ruby rubys at
Thu Sep 4 08:30:46 PDT 2008

Brendan Eich wrote:
> On Sep 3, 2008, at 9:16 PM, Sam Ruby wrote:
>> If typeof(0m) is "number", then !0m should be true.
>> If typeof(0m) is "object", then !0m should be false.
>> If typeof(0m) is "decimal", then we are free to decide what !0m should 
>> be.
>> My preference is for typeof(0m) to be "decimal" and for !0m to be true.
> That's my preference now too, but based on more than aesthetics.

Does that mean that the following need to be revisited?

In particular, does that imply the need for a wrapper class?  First, 
here's existing behavior:

js> 1 instanceof Number
js> Number(1) instanceof Number
js> new Number(1) instanceof Number

And those results correspond to:

js> typeof 0
js> typeof Number(1)
js> typeof new Number(1)

So, what should the following return (where I've filled in the few cases 
where I think the answer is obvious):

js> 1m instanceof Decimal
js> Decimal(1m) instanceof Decimal
js> new Decimal(1m) instanceof Decimal

And the corresponding typeof results:

js> typeof 1m
js> typeof Decimal(1m)
js> typeof new Decimal(1)

Whatever the consensus is, I'll update my SpiderMonkey branch to match 
and then will post the updated test results.

- Sam Ruby

More information about the Es-discuss mailing list