Re: [Json] Limitations on number size?

"Peter F. Patel-Schneider" <pfpschneider@gmail.com> Wed, 10 July 2013 00:16 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 F240011E80D3 for <json@ietfa.amsl.com>; Tue, 9 Jul 2013 17:16:42 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.436
X-Spam-Level:
X-Spam-Status: No, score=-2.436 tagged_above=-999 required=5 tests=[AWL=0.163, 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 BQ8XVqxe1Fok for <json@ietfa.amsl.com>; Tue, 9 Jul 2013 17:16:41 -0700 (PDT)
Received: from mail-ob0-x231.google.com (mail-ob0-x231.google.com [IPv6:2607:f8b0:4003:c01::231]) by ietfa.amsl.com (Postfix) with ESMTP id ED80911E8140 for <json@ietf.org>; Tue, 9 Jul 2013 17:16:39 -0700 (PDT)
Received: by mail-ob0-f177.google.com with SMTP id ta17so7658449obb.36 for <json@ietf.org>; Tue, 09 Jul 2013 17:16:39 -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=huQz9oQLNs8nv6pE2URcyxGN1PygJZPwvjVJR9DkvOY=; b=Ky+EihmssE3hwdHGm1lH1kEaNy5O+aJi87sImIIluiCjHgmCwZdbhsL/PO4LJfhVoV r2BSycQ7h/FLrQ6fsL9AeDbehSM3MZ8IONHMcyMfs1aLXZdjsIcPsouRl6OEJGXwqaoU gcU8TZDulT21cdCxUwJ0Lu1/rDUZIom5EVAIxWEsbQqHYkj7Kxf6Zd6VM3xGIEVCSOou lHyi8zzVDykDhZF1z2NKY4mDUaFiuuNHv8qhgH/9I8/fyWlm7N4McupKkybXGGW134b6 NUwp8b8YN6vPwRp2+GXXUw5H82JHtics6HjarsXJv6PghCPn6Soi6iDacLj+SFTfcT4T N34w==
X-Received: by 10.60.45.229 with SMTP id q5mr26002749oem.79.1373415399356; Tue, 09 Jul 2013 17:16:39 -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 df11sm41772456oec.0.2013.07.09.17.16.35 for <multiple recipients> (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 09 Jul 2013 17:16:38 -0700 (PDT)
Message-ID: <51DCA7DD.8060807@gmail.com>
Date: Tue, 09 Jul 2013 17:16:29 -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: Jorge Chamorro <jorge@jorgechamorro.com>
References: <51DC0F95.7010407@gmail.com> <hf8ot8hnpa93pi3t54c4d5qcc3p5tnb3ca@hive.bjoern.hoehrmann.de> <CAK3OfOgTNaLpRthrRcU4Bo+3z1aXUOOn0Ord7RBPN8z6TtiiWw@mail.gmail.com> <51DC7F87.6060503@gmail.com> <D3773B95-FF52-45D7-BE9F-2DEC92AFA67E@jorgechamorro.com> <51DC92B1.7000908@gmail.com> <A1BB87DE-6377-411A-9359-0714C1CC9549@jorgechamorro.com>
In-Reply-To: <A1BB87DE-6377-411A-9359-0714C1CC9549@jorgechamorro.com>
Content-Type: text/plain; charset="ISO-8859-1"; format="flowed"
Content-Transfer-Encoding: 7bit
Cc: Nico Williams <nico@cryptonector.com>, 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: Wed, 10 Jul 2013 00:16:43 -0000

*Any* number?  Not so!  Assuming sane rules, JSON numbers are inadequate for 
representing all rationals, and the same holds, of course, for any superset of 
the rationals, including reals and complex.  (Yes, yes, no usable data format 
can represent all the reals or complex numbers.)

JSON numbers are unlike the numeric type system of any programming language 
that I had been familiar with, even LISP.  That JSON numbers are so close to 
ECMAScript numeric literals is, to me, a very strong indication that JSON 
numbers are supposed to represent ECMAScript numbers.

I do agree that implementations may be range-restricted, and that a data 
interchange format shouldn't always nail the ranges down exactly.   However, 
floats (being rather unusual numbers) are one place where it can be fruitful 
to nail things completely down.

Peter F. Patel-Schneider



On 07/09/2013 04:24 PM, Jorge Chamorro wrote:
> On 10/07/2013, at 00:46, Peter F. Patel-Schneider wrote:
>>
>> OK, then, what I inferred was that a JSON number represents an IEEE floating point double and I was very surprised to find out that this was not the case.
> And given the super-simple rules in the RFC *any* number can be properly represented which is -it seems to me- exactly what Crockford had in mind: that JSON (the data interchange format) does not impose the limits.
>
> That the platforms, languages, libraries, and stringify()er and parse()r implementations may have numeric data type limitations, isn't JSON's (the data interchange format) business.