Revisiting Decimal

Kris Zyp kris at
Wed Jan 14 16:44:26 PST 2009

Hash: SHA1

Brendan Eich wrote:
> On Jan 9, 2009, at 3:08 PM, Kris Zyp wrote:
>> Hash: SHA1
>>> The counter-argument is strong:
>>> typeof x == typeof y => (x == y <=> x === y)
>>> but 1.1 != 1.1m for fundamental reasons.
>> I understand the counter-argument, but with such an overwhelming
>> number of typeof uses having far easier migration with "number",
> Migration how? You'll have to change something to "use decimal" or
> s/1.1/1.1m/. Only once you do that can you be sure about all
> operands being decimal.
And I am sure our users will do that and pass decimals into our
library functions.
> I'm assuming it would be "bad" in the Dojo code you've looked at if
> 1.1 came in from some standard library that returns doubles, and was
> tested against 1.1m via == or === with false result, where previous
> to decimal being added, the result would be true.
I am not aware of any situations in the Dojo codebase where this would
cause a problem. I can't think of any place where we use an
equivalence test and users would expect that decimal behave in the
same way as a double. Do you have any expected pitfalls that I could
look for in Dojo?

>> I can't possibly see how the desire to preserve this property is more
>> important than better usability for the majority use cases.
> You really need to show some of these use cases from Dojo. I have a
> hard time believing you've ruled out mixed-mode accidents.
Ok, sounds good, I will be glad to be corrected if I misunderstanding
this. Here are some of the places where I believe we would probably
add extra code to handle the case of typeof checks where decimal
values may have been passed in by users, and we would want the
behavior to be the same as a number:
As I have mentioned before, we would need to change our JSON
serializer to handle "decimal":
(line 118)
Our parser function would need to add support for "decimal"
(line 32)
Matrix math handling for our graphics module:
(line 88 is one example)
Actually there are numerous situations in the graphics packages where
a decimal should be acceptable for defining coordinates, scaling, etc.:
Charting also has a number of places where decimals should be an
acceptable form of a number:
For example:
(line 22)

Again, I understand there are difficulties with typeof 1.1m returning
"number", but in practice it seems we would experience far more pain
with "decimal".

- --
Kris Zyp
(503) 806-1841

Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla -

More information about the Es-discuss mailing list