Re: [Json] Limitations on number size?

"Peter F. Patel-Schneider" <> Tue, 09 July 2013 21:24 UTC

Return-Path: <>
Received: from localhost (localhost []) by (Postfix) with ESMTP id B935821F9D3B for <>; Tue, 9 Jul 2013 14:24:28 -0700 (PDT)
X-Virus-Scanned: amavisd-new at
X-Spam-Flag: NO
X-Spam-Score: -2.849
X-Spam-Status: No, score=-2.849 tagged_above=-999 required=5 tests=[AWL=-0.250, BAYES_00=-2.599]
Received: from ([]) by localhost ( []) (amavisd-new, port 10024) with ESMTP id Dn0EgmVFBkP2 for <>; Tue, 9 Jul 2013 14:24:28 -0700 (PDT)
Received: from ( [IPv6:2607:f8b0:4003:c01::22c]) by (Postfix) with ESMTP id 2793C21F99BB for <>; Tue, 9 Jul 2013 14:24:28 -0700 (PDT)
Received: by with SMTP id wo10so7450679obc.17 for <>; Tue, 09 Jul 2013 14:24:27 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=8QJ2lgnF7fU3mDQyxWj31Ro5YpUejgntPkZvH3TWMXg=; b=btflXhr4OgCEWvlw4y3ZsrhhIkN1bNSelvBL5ZapCQJv4zZ0m6Oxe48ThjxvW0XofE FG+MqtHBgt6idzHqSMbKvpCkhFpqjRycLAfd4YSpPKEaGAOS/xHdF7aRcn92qXGsPVLn a5Au0GgRbPPiHHbIO96kJ7TSaxPPHRnWofT95EDLjTtF5dUHWk/GSGDTQU3M9Fg2qND7 tjYVVTCaOVG+vkF1JRo85mHvzyfudsnO81I+f3k1Z1EA1ZKM1qNPcKWqpXRnjNBwHOu1 n3nOrQshWTYx7g2wc6tgupPJXKqlFXtFxNTx8a6B5uAwnMq05mny809lo9JA54yE61y7 8aPg==
X-Received: by with SMTP id n10mr25429316oem.101.1373405067703; Tue, 09 Jul 2013 14:24:27 -0700 (PDT)
Received: from [] ( []) by with ESMTPSA id qa4sm40911879oeb.5.2013. for <multiple recipients> (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 09 Jul 2013 14:24:25 -0700 (PDT)
Message-ID: <>
Date: Tue, 09 Jul 2013 14:24:23 -0700
From: "Peter F. Patel-Schneider" <>
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130514 Thunderbird/17.0.6
MIME-Version: 1.0
To: Nico Williams <>
References: <> <> <>
In-Reply-To: <>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Cc: Bjoern Hoehrmann <>,
Subject: Re: [Json] Limitations on number size?
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: "JavaScript Object Notation \(JSON\) WG mailing list" <>
List-Unsubscribe: <>, <>
List-Archive: <>
List-Post: <>
List-Help: <>
List-Subscribe: <>, <>
X-List-Received-Date: Tue, 09 Jul 2013 21:24:28 -0000

[Somewhat less facetious.]

Where does this end?   Do I have to worry about whether, for example, 0.0 is 
different from 0.00?   (Some people, e.g., numerical analysts, would argue 
that they are different - the first is 0+-0.05 and the second is 0+-0.005.)  
Do I have to worry about whether 0.1 is different from 1E-1?  (Some people, 
e.g., XML-philes, might argue that the first is a decimal and the second is a 
float or double.) Do I have to worry about whether 0 is different from 0.?  
(Some people, e.g., C programmers, might argue that 0 is an int and 0. is a 

Searching for answers to these questions lead me various bits of RFC 4627.

I looked at "The representation of numbers is similar to that used in most 
programming languages."  However, the only programming language that I was 
acquainted with that had a single number type encompassing scientific notation 
was LISP.   Most other languages that I could recall, e.g., C, C++, and ML, 
had at least a distinction between integers and floats.   Java sort of splits 
the difference.   So this really didn't provide me with any guidance.

This lead me to the beginning of the document and the "is derived from the 
ECMAScript Programming Language Standard" and the "JSON defines a small set of 
formatting rules for the portable representation of structured data."

Finally, some guidance!  Hopefully ECMAScript will tell me how numbers in JSON 
can be portably interpreted as data.   So I read the ECMAScript document.  
Success!  The ECMAScript document tells me, in gory detail, how to interpret 
something that looks like JSON numbers and, moreover, provides a datatype for 
these numbers, namely IEEE floating point double.

So that is how I came up with JSON numbers being IEEE floating point double.

Imagine my surprise when I was told that my reasoning was not correct.

Peter F. Patel-Schneider

On 07/09/2013 09:37 AM, Nico Williams wrote:
> On Tue, Jul 9, 2013 at 11:23 AM, Bjoern Hoehrmann <> wrote:
>> I think it is well-understood that if you need particularily small,
>> big, precise or otherwise unusual numbers in JSON then it's best to
>> encode them as strings so you can do the string-to-number conversion
>> at a higher level than whatever JSON library you might be using today.
> <semifacetious>
> If that's what we should always do then why can't parsers do it automatically?
> </semifacetious>
> _______________________________________________
> json mailing list