A directive to solve the JavaScript arithmetic precision issue

Sam Tobin-Hochstadt samth at ccs.neu.edu
Mon Aug 15 12:32:18 PDT 2011


On Mon, Aug 15, 2011 at 1:33 PM, David Bruant <david.bruant at labri.fr> wrote:
>
> I have been watching JSConf talks recently and two of them [1] [2]
> mentionned the issue that JavaScript has with numbers. Something than
> prevent JS to be a good language to interact with a database.

> The lack
> of 64-bits integers is also mentionned.

[snip]

> var a = 0.1 + 0.2; // 0.3 // FINALLY!

It's important to note that these are two very different problems, and
they almost certainly have very different solutions.  In particular,
adding any sort of integers won't make 0.1 change behavior.
Similarly, one possible solution to the 0.1 issue is decimal floating
point, which doesn't give you a 64-bit integer range.

Numbers are a very big problem space, and the choices made in JS have
multiple issues (as well as some benefits).  It's important to be
clear on what we want to fix before we start trying to fix it.
-- 
sam th
samth at ccs.neu.edu


More information about the es-discuss mailing list