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

Tim Bray <tbray@textuality.com> Thu, 22 May 2014 15:48 UTC

Return-Path: <tbray@textuality.com>
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 A14751A0178 for <json@ietfa.amsl.com>; Thu, 22 May 2014 08:48:19 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.977
X-Spam-Level:
X-Spam-Status: No, score=-1.977 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, FM_FORGED_GMAIL=0.622, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7] 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 ex5NGPuII-0H for <json@ietfa.amsl.com>; Thu, 22 May 2014 08:48:14 -0700 (PDT)
Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id CF1961A01DD for <json@ietf.org>; Thu, 22 May 2014 08:48:13 -0700 (PDT)
Received: by mail-vc0-f173.google.com with SMTP id il7so4678894vcb.18 for <json@ietf.org>; Thu, 22 May 2014 08:48:12 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=PDbPhJgFNJsS+itYTg2/GGRx8wsiflfWH4mZIDxSg0k=; b=PRBHbHmb6TXbZEomAqtNJlJaVYSsdtH3AcGdeZedM3NhXx0pplxvIZNJ6MyLQPeqQt AK8Q15hSso/E7HRJ1uQJH7+SvG4CvfmMttZKz9M/WtoMAfJ9hgsZqCxzLEUbZHlFHLhs Lf7yYeoxkAdgyxwGCK/KAIeJ5MXQN9Rq6E0GKJ2gzflpr0EGipFuZDMyX/GUHx80RRvB f5V4CRjevhirCKhKLUe6iBMEchYOUJtfP6Wa2ZdaH7fdaF0k7rTbR8kcCs++P0i9hGyU bOeZ4ijrYKbjexCps1gI9zJxQcacvu2/EB9flawZPu/mXSHz2wmCRSSuQaulW0bCUHt5 veyw==
X-Gm-Message-State: ALoCoQnytPoRzmNb/dhvi+/J1FMr5Y9/+M2UrHLhqMVqEzbAILjMQWqEO5En+dC3SkeZkV/l3YCe
X-Received: by 10.58.39.129 with SMTP id p1mr975678vek.69.1400773691891; Thu, 22 May 2014 08:48:11 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.220.98.73 with HTTP; Thu, 22 May 2014 08:47:51 -0700 (PDT)
X-Originating-IP: [65.114.90.17]
In-Reply-To: <255B9BB34FB7D647A506DC292726F6E1154629E87D@WSMSG3153V.srv.dir.telstra.com>
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> <20140521020731.GG9283@mercury.ccil.org> <CFA21B5C.4A721%jhildebr@cisco.com> <255B9BB34FB7D647A506DC292726F6E1154629E87D@WSMSG3153V.srv.dir.telstra.com>
From: Tim Bray <tbray@textuality.com>
Date: Thu, 22 May 2014 10:47:51 -0500
Message-ID: <CAHBU6isO7oooeN8rH8emx-xuOrs2yzBUrhyJNYYAyzK2-QfF0w@mail.gmail.com>
To: "Manger, James" <James.H.Manger@team.telstra.com>
Content-Type: multipart/alternative; boundary=089e013cc4a450fa0e04f9ff0afd
Archived-At: http://mailarchive.ietf.org/arch/msg/json/NbLxZ4sjDCPPNLvaeVEzL4h6I7E
Cc: Carsten Bormann <cabo@tzi.org>, "Matt Miller \(mamille2\)" <mamille2@cisco.com>, John Cowan <cowan@mercury.ccil.org>, "Joe Hildebrand \(jhildebr\)" <jhildebr@cisco.com>, IETF JSON WG <json@ietf.org>
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: Thu, 22 May 2014 15:48:19 -0000

​Since I don’t pretend to much expertise in the finer points of numeric
representation, let me play referee.  I draw your attention to
http://tools.ietf.org/html/draft-bray-i-json-01#section-2.2 which is what
we’re trying to improve here.
- I think the second para, saying “Use strings if your numbers are too
big/precise”, is uncontroversial.
- I think the current first paragraph is also reasonably OK in the sense
that what it says is in fact correct.
- There is also a substantial body of knowledge around the number-wrangling
facts such as that there are lots of nice simple short decimally-expressed
numbers that are not going to round-trip.
- Also, the language in RFC7159 makes useful points such as what range of
integers will successfully round-trip and it is effectively included by
reference.

My take-away is that leaving the text as in i-json-01 would not be
terrible.  On re-reading this thread, I’m not sure I see any single
suggestion for expanding that text that someone else hasn’t successfully
nit-picked, except for John’s

"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."

And I'm not even sure that really adds much value.  If we start enumerating
all the gotchas that can getcha when you’re converting textual and binary
representations of numeric quantities back and forth, this is gonna be a
big long text.


On Wed, May 21, 2014 at 7:45 PM, Manger, James <
James.H.Manger@team.telstra.com> wrote:

> >"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.
>
> This is wrong (in its implication that other numbers are exact).
> Neither I-JSON nor JSON requires numbers to be held internally as a
> double. I-JSON simply recognizes that doubles are common so you can expect
> at least the precision & range of a double. You cannot expect values
> between 1e-308 and 1e308 to be treated exactly. One receiver might round it
> to the nearest double, another might use a BigDecimal class (treating it
> exactly). The non-exactness doesn't change abruptly at 1e308 or 1e-308
> either.
>
> --
> James Manger
>
> _______________________________________________
> json mailing list
> json@ietf.org
> https://www.ietf.org/mailman/listinfo/json
>



-- 
- Tim Bray (If you’d like to send me a private message, see
https://keybase.io/timbray)