On Jun 23, 2009, at 12:18 AM, Christian Plesner Hansen wrote:
I've been looking around on the web for reasons why decimal arithmetic
should be added to ES. The most extensive page I could find was
http://speleotrove.com/decimal/decifaq.html. If anyone know other
good sources of information about decimal and its inclusion in ES
please follow up.
Mike Cowlishaw's pages on decimal have lots of arguments for it:
http://www2.hursley.ibm.com/decimal/decifaq.html
http://www2.hursley.ibm.com/decimal/
The most-duplicated JS bug in bugzilla.mozilla.org is
https://bugzilla.mozilla.org/show_bug.cgi?id=5856
Here's a typical naive JS user complaining that his computer his
broken because it can't calculate correct differences:
"... I typed in:
9533.24-215.10
… and here is the garbage Apple babbled back at me: 9318.139999999999"
He blamed Apple. Naive users often blame hardware for software bugs.
The strongest argument seems to be financial: binary arithmetic is
approximate in a way that makes it unsuitable for financial
calculations. I buy this argument in general -- I would definitely
want my bank to use some form of decimal arithmetic rather than binary
-- but less so in the context of ES.
Do you consider that naive user's calculator example to be
"financial"? I do not.
The problem is worse for non-experts. The experts can cope.
Anyway, decimal is not being pushed into JS at this point. At the last
face-to-face TC39 meeting, we changed direction to explore
generalizing value type support (including operators and literals if
we can) so that libraries could add first class number-like types.
Whether any new value type would be native or self-hosted, and whether
it would be included in the core standard, are issues we want to defer
until later, ideally until there are de-facto standards to codify.
The counter-argument articulated at the meeting by Sam was that it's
rare for users to download binary extensions to JS for browsers (Flash
is the only exception, and it's not primarily a JS extension). So
users won't get decimal unless it is part of the normative core spec,
so the usability bug reported as Mozilla bug 5856 won't get fixed.
I think Sam has a point; lack of a standard could be a problem. But
whatever we do about it, the committee agreed to work on value types
first. They're on the Harmony agenda.
/be
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss