JSON numbers (was: Revisiting Decimal)

Brendan Eich brendan at mozilla.com
Thu Jan 15 18:24:06 PST 2009


On Jan 15, 2009, at 6:07 PM, David-Sarah Hopwood wrote:

> That approximation might be good enough for a particular use of JSON;
> if it isn't, then the application programmer should use a different
> binding, or different options to the binding.

To cut past all the preaching to the choir: the argument we were  
having, apart from any confusions, is about what the default options  
to the ES Harmony binding should be.


> None of this dictates a specific answer to what 'typeof aDecimal'
> should return, but it needs to be clarified lest we do violence to
> JSON's intended semantics by making incorrect assumptions about it.

JSON's intended semantics may be arbitrary precision decimal (the RFC  
is neither explicit nor specific enough in my opinion; it mentions  
only "range", not "precision"), but not all real-world JSON codecs use  
arbitrary precision decimal, and in particular today's JS codecs use  
IEEE double binary floating point. This "approximates" by default and  
creates a de-facto standard that can't be compatibly extended without  
opt-in.

/be


More information about the Es-discuss mailing list