Re: [Json] Limitations on number size?

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

Return-Path: <pfpschneider@gmail.com>
X-Original-To: json@ietfa.amsl.com
Delivered-To: json@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id B935821F9D3B for <json@ietfa.amsl.com>; Tue, 9 Jul 2013 14:24:28 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.849
X-Spam-Level:
X-Spam-Status: No, score=-2.849 tagged_above=-999 required=5 tests=[AWL=-0.250, BAYES_00=-2.599]
Received: from mail.ietf.org ([12.22.58.30]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Dn0EgmVFBkP2 for <json@ietfa.amsl.com>; Tue, 9 Jul 2013 14:24:28 -0700 (PDT)
Received: from mail-ob0-x22c.google.com (mail-ob0-x22c.google.com [IPv6:2607:f8b0:4003:c01::22c]) by ietfa.amsl.com (Postfix) with ESMTP id 2793C21F99BB for <json@ietf.org>; Tue, 9 Jul 2013 14:24:28 -0700 (PDT)
Received: by mail-ob0-f172.google.com with SMTP id wo10so7450679obc.17 for <json@ietf.org>; Tue, 09 Jul 2013 14:24:27 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; 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 10.60.45.138 with SMTP id n10mr25429316oem.101.1373405067703; Tue, 09 Jul 2013 14:24:27 -0700 (PDT)
Received: from [192.168.1.102] (out-on-158.wireless.telus.com. [207.219.69.158]) by mx.google.com with ESMTPSA id qa4sm40911879oeb.5.2013.07.09.14.24.25 for <multiple recipients> (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 09 Jul 2013 14:24:25 -0700 (PDT)
Message-ID: <51DC7F87.6060503@gmail.com>
Date: Tue, 09 Jul 2013 14:24:23 -0700
From: "Peter F. Patel-Schneider" <pfpschneider@gmail.com>
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130514 Thunderbird/17.0.6
MIME-Version: 1.0
To: Nico Williams <nico@cryptonector.com>
References: <51DC0F95.7010407@gmail.com> <hf8ot8hnpa93pi3t54c4d5qcc3p5tnb3ca@hive.bjoern.hoehrmann.de> <CAK3OfOgTNaLpRthrRcU4Bo+3z1aXUOOn0Ord7RBPN8z6TtiiWw@mail.gmail.com>
In-Reply-To: <CAK3OfOgTNaLpRthrRcU4Bo+3z1aXUOOn0Ord7RBPN8z6TtiiWw@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Cc: Bjoern Hoehrmann <derhoermi@gmx.net>, json@ietf.org
Subject: Re: [Json] Limitations on number size?
X-BeenThere: json@ietf.org
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: "JavaScript Object Notation \(JSON\) WG mailing list" <json.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/json>, <mailto:json-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/json>
List-Post: <mailto:json@ietf.org>
List-Help: <mailto:json-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/json>, <mailto:json-request@ietf.org?subject=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 
float.)

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 <derhoermi@gmx.net> 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
> json@ietf.org
> https://www.ietf.org/mailman/listinfo/json