Re: [Json] Limitations on number size?

Jorge Chamorro <jorge@jorgechamorro.com> Tue, 09 July 2013 22:20 UTC

Return-Path: <jorge@jorgechamorro.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 DE48521F9799 for <json@ietfa.amsl.com>; Tue, 9 Jul 2013 15:20:08 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.999
X-Spam-Level:
X-Spam-Status: No, score=-2.999 tagged_above=-999 required=5 tests=[BAYES_00=-2.599, J_CHICKENPOX_66=0.6, RCVD_IN_DNSWL_LOW=-1]
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 RsmHYOGICmg1 for <json@ietfa.amsl.com>; Tue, 9 Jul 2013 15:20:03 -0700 (PDT)
Received: from mail-we0-f171.google.com (mail-we0-f171.google.com [74.125.82.171]) by ietfa.amsl.com (Postfix) with ESMTP id BDE2F11E816F for <json@ietf.org>; Tue, 9 Jul 2013 15:20:02 -0700 (PDT)
Received: by mail-we0-f171.google.com with SMTP id m46so5228103wev.16 for <json@ietf.org>; Tue, 09 Jul 2013 15:20:01 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer :x-gm-message-state; bh=3qnbLnRUHjN4gY86FMH2qDQXygYDRYaRgIWwFPJvd9k=; b=iZRfkW+8iIfLYMzK/HqlL53Yy+GeUgUPbDnMNhrpoySxVuUehddC4b6sOoYH5UHvdA ztQYtxkNzkswJpti7XuTiBnlzzp2HrxOmbLRdFIYCXp1ZQ9azwv1bUcU46hWmQZH/wPx LLpNHozFhFySnUT+u13OeqRp/C6WWTboHaKkc8ZIqw5KNCCT/jskdqMPd5IQTOO2Eohn tUxOy5mOVHCU8xIybgbGfTQuG81cIp1TV1BY+YgzWrBjPKnb8yu6T5bUzoWZz0321uo1 VUdBqBRTjeGTCf8Vl0lttV5MNNXEgIiVTYbx5PyA9O88zHJwOJImys9vE+IRfokdg35x gDUA==
X-Received: by 10.180.38.45 with SMTP id d13mr15411841wik.62.1373408401417; Tue, 09 Jul 2013 15:20:01 -0700 (PDT)
Received: from [192.168.10.50] (11.Red-88-0-221.dynamicIP.rima-tde.net. [88.0.221.11]) by mx.google.com with ESMTPSA id fb2sm63803080wic.4.2013.07.09.15.20.00 for <multiple recipients> (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Jul 2013 15:20:00 -0700 (PDT)
Mime-Version: 1.0 (Apple Message framework v1085)
Content-Type: text/plain; charset=us-ascii
From: Jorge Chamorro <jorge@jorgechamorro.com>
In-Reply-To: <51DC7F87.6060503@gmail.com>
Date: Wed, 10 Jul 2013 00:19:58 +0200
Content-Transfer-Encoding: quoted-printable
Message-Id: <D3773B95-FF52-45D7-BE9F-2DEC92AFA67E@jorgechamorro.com>
References: <51DC0F95.7010407@gmail.com> <hf8ot8hnpa93pi3t54c4d5qcc3p5tnb3ca@hive.bjoern.hoehrmann.de> <CAK3OfOgTNaLpRthrRcU4Bo+3z1aXUOOn0Ord7RBPN8z6TtiiWw@mail.gmail.com> <51DC7F87.6060503@gmail.com>
To: "Peter F. Patel-Schneider" <pfpschneider@gmail.com>
X-Mailer: Apple Mail (2.1085)
X-Gm-Message-State: ALoCoQnF9//B5RX9hY6GB/2mM7SxHMSdOy91qPCFcyPf9kxe29YXrtOP9FWpOUU6RBPo4A/miRMY
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: Tue, 09 Jul 2013 22:20:09 -0000

On 09/07/2013, at 23:24, Peter F. Patel-Schneider wrote:
> 
> Imagine my surprise when I was told that my reasoning was not correct.

A "JSON number" is a *text* not a number:

number = [ minus ] int [ frac ] [ exp ]

         decimal-point = %x2E       ; .

         digit1-9 = %x31-39         ; 1-9

         e = %x65 / %x45            ; e E

         exp = e [ minus / plus ] 1*DIGIT

         frac = decimal-point 1*DIGIT

         int = zero / ( digit1-9 *DIGIT )

         minus = %x2D               ; -

         plus = %x2B                ; +

         zero = %x30                ; 0

A character representation of a number that follows the rules in the RFC 4627 that -unlike ECMAScript- doesn't say a thing about its precision, integer-ness, floating-point-ness, allowable ranges or the likes.


To say that a "JSON number" (which is a text) is === IEEE-754 double doesn't make too much sense.


JSON.stringify(number:number) -> text:JSON_number
JSON.parse(text:JSON_number)  -> number:number
-- 
( Jorge )();