JSON numbers (was: Revisiting Decimal)

Brendan Eich brendan at mozilla.com
Fri Jan 16 18:33:12 PST 2009

On Jan 15, 2009, at 7:28 PM, Sam Ruby wrote:

> On Thu, Jan 15, 2009 at 9:24 PM, Brendan Eich <brendan at mozilla.com>  
> wrote:
>> 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.
> You might find the next link enlightening or perhaps even a pleasant  
> diversion:
> http://www.intertwingly.net/stories/2002/02/01/toInfinityAndBeyondTheQuestForSoapInteroperability.html
> Quick summary as it applies to this discussion: perfection is
> unattainable (duh!) and an implementation which implements JSON
> numbers as quad decimal will retain more precision than one that
> implements JSON numbers as double binary (duh!).

DuhT^2 ;-).

But more than that: discounting the plain fact that on the web at  
least, SOAP lost to JSON (Google dropped its SOAP APIs a while ago),  
do you draw any conclusions?

My conclusion, crustier and ornier as I age, is that mixed-mode  
arithmetic with implicit conversions and "best effort" "approximation"  
is a botch and a blight. That's why I won't have it in JSON, encoding  
*and* decoding.


More information about the Es-discuss mailing list