Re: [Json] I-JSON Topic #5: Numbers

John Cowan <cowan@mercury.ccil.org> Wed, 21 May 2014 02:07 UTC

Return-Path: <cowan@ccil.org>
X-Original-To: json@ietfa.amsl.com
Delivered-To: json@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 8E1321A0411 for <json@ietfa.amsl.com>; Tue, 20 May 2014 19:07:48 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -3.251
X-Spam-Level:
X-Spam-Status: No, score=-3.251 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RP_MATCHES_RCVD=-0.651] autolearn=ham
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id x0PN6YtBc92l for <json@ietfa.amsl.com>; Tue, 20 May 2014 19:07:46 -0700 (PDT)
Received: from earth.ccil.org (earth.ccil.org [192.190.237.11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 2AA841A040E for <json@ietf.org>; Tue, 20 May 2014 19:07:46 -0700 (PDT)
Received: from cowan by earth.ccil.org with local (Exim 4.72) (envelope-from <cowan@ccil.org>) id 1WmvwJ-00068H-OK; Tue, 20 May 2014 22:07:31 -0400
Date: Tue, 20 May 2014 22:07:31 -0400
From: John Cowan <cowan@mercury.ccil.org>
To: "Manger, James" <James.H.Manger@team.telstra.com>
Message-ID: <20140521020731.GG9283@mercury.ccil.org>
References: <535EB3BF.8080606@cisco.com> <CAHBU6ivjF9ULW0yGSVdJi2D6QgUThuhym_ZhpgLM=cvLu=mAiQ@mail.gmail.com> <CF841AAE.47D86%jhildebr@cisco.com> <CAHBU6itK5HtSTPWSsHsHUPja90emqU86LsgjrBorkqcUDivS2A@mail.gmail.com> <CF87EB9C.48BB0%jhildebr@cisco.com> <537A5BE0.3020406@cisco.com> <CF9FCEC9.4A4E7%jhildebr@cisco.com> <488AE66E-725D-40B3-9FDA-ADA1018BCF65@tzi.org> <CFA0F09E.4A609%jhildebr@cisco.com> <255B9BB34FB7D647A506DC292726F6E115461FFE59@WSMSG3153V.srv.dir.telstra.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: inline
In-Reply-To: <255B9BB34FB7D647A506DC292726F6E115461FFE59@WSMSG3153V.srv.dir.telstra.com>
User-Agent: Mutt/1.5.20 (2009-06-14)
Sender: John Cowan <cowan@ccil.org>
Archived-At: http://mailarchive.ietf.org/arch/msg/json/DL9n-WzcB8gS_vbuI3y8j1e9ezQ
Cc: Carsten Bormann <cabo@tzi.org>, IETF JSON WG <json@ietf.org>, "Joe Hildebrand (jhildebr)" <jhildebr@cisco.com>, "Matt Miller (mamille2)" <mamille2@cisco.com>
Subject: Re: [Json] I-JSON Topic #5: Numbers
X-BeenThere: json@ietf.org
X-Mailman-Version: 2.1.15
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, 21 May 2014 02:07:48 -0000

Manger, James scripsit:

> Less precision than an "average" double maybe,
> but not less than you *expect* for a double.

It's the "chop to zero" that's a problem for i14y.

> The 1e-308 and 1e308 limits for full precision are a key part (and an
> expected part) of a double.

+1

> The best we can probably do is say that "an I-JSON message
> MUST NOT expect a receiver to treat an integer as the exact value
> given (distinct from integers differing by 1) if it is greater than
> 9007199254740992".

Almost.

"An I-JSON sender MUST NOT expect a receiver to treat a non-zero number
whose absolute value is greater than 1e308 or less than 1e-308
as an exact value.  Furthermore, an I-JSON sender MUST NOT expect a
receiver to treat an integer whose absolute value is greater than
9007199254740992 as an exact value."

>   {"x":123456789012345680000}
> 
>   {"y":123456789012345678901}

This is a special case of the above rules: these are both mathematically
1.2345678901234568e+20.

-- 
John Cowan          http://www.ccil.org/~cowan        cowan@ccil.org
By Elbereth and Luthien the Fair, you shall have neither the Ring nor me!
                --Frodo