Re: [Json] Limitations on number size?

Stephan Beal <sgbeal@googlemail.com> Wed, 10 July 2013 10:15 UTC

Return-Path: <sgbeal@googlemail.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 1129121F894E for <json@ietfa.amsl.com>; Wed, 10 Jul 2013 03:15:24 -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=[AWL=-0.000, BAYES_00=-2.599, FM_FORGED_GMAIL=0.622, HTML_MESSAGE=0.001, NO_RELAYS=-0.001]
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 vCydc2qWVvzB for <json@ietfa.amsl.com>; Wed, 10 Jul 2013 03:15:23 -0700 (PDT)
Received: from mail-pa0-x229.google.com (mail-pa0-x229.google.com [IPv6:2607:f8b0:400e:c03::229]) by ietfa.amsl.com (Postfix) with ESMTP id 2926F21F8526 for <json@ietf.org>; Wed, 10 Jul 2013 03:15:23 -0700 (PDT)
Received: by mail-pa0-f41.google.com with SMTP id bj3so6586723pad.0 for <json@ietf.org>; Wed, 10 Jul 2013 03:15:22 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=Kckh47A68Bzi1fglGnM731/kv/Jonu/VeqQau8zUayE=; b=r7pqXUA6bqRQ2T+nPwv7830wUTT6K+CZBUb6vld2mTprxAuuQVHaLtSS48f3NT2qTS DZLIx1Oh0BJaKhsjysFk2inJ3c34YFbTYWRbZJPotVg4Ej5xlNkJrpQI4GyXCaSGj0mX ojoe+e/fLTi7OQ/lVhg3OsAvUy2HWXyrRwa3aaWZb5+xLhiZJNoaXhdpnBE3oLKsvZsB 4m2hclet4OQKwqAwZuHicOxqEUO0K0VdFRIoFEj64ucJHie2JuHu6hYigAzR+hfcduqv NAx1Lnf0wD9rorC7WlXOASLAicDPUhY4rWDiO7IXMt6sxHbNMLOVCnVY/Kol1dwnlHoD h4Cw==
MIME-Version: 1.0
X-Received: by 10.68.36.230 with SMTP id t6mr31079855pbj.15.1373451322516; Wed, 10 Jul 2013 03:15:22 -0700 (PDT)
Received: by 10.68.156.35 with HTTP; Wed, 10 Jul 2013 03:15:22 -0700 (PDT)
In-Reply-To: <51DD3248.3020008@gmail.com>
References: <51DC0F95.7010407@gmail.com> <hf8ot8hnpa93pi3t54c4d5qcc3p5tnb3ca@hive.bjoern.hoehrmann.de> <CAK3OfOgTNaLpRthrRcU4Bo+3z1aXUOOn0Ord7RBPN8z6TtiiWw@mail.gmail.com> <51DC7F87.6060503@gmail.com> <CAGrxA24v5L7oCGxEOwecJSLCNiLrSWSt=jFJMA0M9E8fztNLag@mail.gmail.com> <51DC95B2.8080801@gmail.com> <20130709231139.GC8043@gmail.com> <51DCA042.4000303@gmail.com> <CAKd4nAjHE8_4hWMG7jSzv=_VsoKb-cqNdX4CR+6R-p1WkQnDTQ@mail.gmail.com> <51DD3248.3020008@gmail.com>
Date: Wed, 10 Jul 2013 12:15:22 +0200
Message-ID: <CAKd4nAj66kGWvRGTUtwg_238LuiZ47jRLWAaCho2jH69Qu7ZUg@mail.gmail.com>
From: Stephan Beal <sgbeal@googlemail.com>
To: "json@ietf.org" <json@ietf.org>
Content-Type: multipart/alternative; boundary="bcaec520f2db31f6f504e1258e5b"
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 10:15:24 -0000

On Wed, Jul 10, 2013 at 12:07 PM, Peter F. Patel-Schneider <
pfpschneider@gmail.com> wrote:

> Relatively is one of these weasel words that we all use.


Agreed.



>
> However, the working group mailing archives contain evidence that there
> are indeed significant problems when using JSON to portably interchange
> data, particularly  binary data.


Such cases are their own fault: JSON never, every claimed to be able to
support binary data. Wrong tool for the job, period.


> Implementors tend to use whatever default limits the platform provides
> (e.g. 32-bit on 32-bit platforms and 64 on 64-bit, and 6-digit precision in
> doubles seems to be conventional in C libraries).
>
>> People using high-precision/very large/very small numbers are certainly
>> aware of the limitations/portability problems, and will (possibly after
>> falling on their face with JSON) pick a different format.
>>
>
> Are they really aware of all the potential problems?   And just what
> counts as high-precision/very large/very small?  Does 0. belong to any of
> these categories?


Excellent point - no, they are most certainly not aware of all potential
problems, and that's why they rely on the system-level defaults - because
they know that very smart people have spent time implementing them and
making sure they are reasonable for a wide variety of use cases. Least
common denominator. It would be impossible to expect every JSON parser
implementor to understand the intricacies of binary encodings of floating
point values. (i've implement 3 or 4 JSON parsers in C and C++ and have
never read any of the relevant IEEE docs - i rely on the system to define
my legal ranges).


>> Using your case of 0 vs 0.0. The vast, vast majority of JSON consumers
>> are JavaScript, and JS doesn't differentiate between doubles and integers,
>> so 0 is, in effect equivalent to 0.0. In fact, there are few real-world
>> applications using JSON where the two are _not_ equivalent (barring
>> scientific, high-precision, math-centric apps, of course, and those should
>> probably be looking for a different format which guarantees them their
>> desired ranges/limits).
>>
>
> I would appreciate some evidence to back up the claim that the vast, vast
> majority of JSON is handled in an environment where the JSON numbers 0 and
> 0.0 do indeed represent the same thing.


You're right, and i'll see if i can find some properly collected
statistics. My "evidence" is purely anecdotal - 90+% of the applications i
work with which use JSON are www-based or www-bound.

The RDF W3C workiing group is in the last stages of putting its stamp of
> approval on JSON-LD, which presents the JSON numbers 0 and 0.0 to RDF as
> being different.
>

Different standard - doesn't interest me ;). i don't have a single
application where the difference between 0 and 0.0 is relevant to the
outcome of a calculation (with the minor exception of maybe output
formatting).

-- 
----- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal