Re: [Json] Minus Zero

John Cowan <cowan@mercury.ccil.org> Tue, 21 June 2016 20:41 UTC

Return-Path: <cowan@ccil.org>
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 B61C812D94D for <json@ietfa.amsl.com>; Tue, 21 Jun 2016 13:41:55 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.027
X-Spam-Level:
X-Spam-Status: No, score=-4.027 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RP_MATCHES_RCVD=-1.426, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
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 7MHGqr926iI1 for <json@ietfa.amsl.com>; Tue, 21 Jun 2016 13:41:54 -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 593CE12D94A for <json@ietf.org>; Tue, 21 Jun 2016 13:41:54 -0700 (PDT)
Received: from cowan by earth.ccil.org with local (Exim 4.72) (envelope-from <cowan@ccil.org>) id 1bFSUZ-0003bh-5N; Tue, 21 Jun 2016 16:41:51 -0400
Date: Tue, 21 Jun 2016 16:41:51 -0400
From: John Cowan <cowan@mercury.ccil.org>
To: Anders Rundgren <anders.rundgren.net@gmail.com>
Message-ID: <20160621204150.GJ13605@mercury.ccil.org>
References: <2a7f88b9-f719-dfd8-08a9-1777833e53d8@gmail.com> <e94f3bd0-1635-b2e1-c5da-9ae350ae652d@gmail.com> <57684982.2010705@tzi.org> <8e5dc4b2-a897-30e7-6e37-921c463275cd@gmail.com> <CADEL5zv-0ZRdcXKp1R=EBHqcJquOR7CYR=EW75xmtFpXG5OLOg@mail.gmail.com> <20160621154243.GG13605@mercury.ccil.org> <6d834be1-14c3-d8b4-09dd-2a992cfe55a6@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: inline
In-Reply-To: <6d834be1-14c3-d8b4-09dd-2a992cfe55a6@gmail.com>
User-Agent: Mutt/1.5.20 (2009-06-14)
Sender: John Cowan <cowan@ccil.org>
Archived-At: <https://mailarchive.ietf.org/arch/msg/json/-Ipm65AmTyp1Bozeuaz2GCaIK6c>
Cc: Carsten Bormann <cabo@tzi.org>, Christian Zangl <coralllama@gmail.com>, JSON WG <json@ietf.org>
Subject: Re: [Json] Minus Zero
X-BeenThere: json@ietf.org
X-Mailman-Version: 2.1.17
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: <https://mailarchive.ietf.org/arch/browse/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, 21 Jun 2016 20:41:56 -0000

Anders Rundgren scripsit:

> Apparently the ES6 folks consider IEEE 0.0 and -0.0 equal during JSON
> serialization.

In effect that means that -0, like NaN and Infinity and -Infinity, can't
be serialized correctly as JSON.  But instead of being serialized as null,
it's serialized the same as 0.

> In order to make anything else JSON would need separate integer and
> floating point types.

I don't understand that.  JavaScript's internal model of numbers already
includes -0.0 (e.g. the value of the expression 1/(-1*0) is -Infinity).
The node.js and Chrome REPLs will print -0 in appropriate circumstances
(whereas the Rhino and Edge REPLs will not).

-- 
John Cowan          http://www.ccil.org/~cowan        cowan@ccil.org
But the next day there came no dawn, and the Grey Company passed on
into the darkness of the Storm of Mordor and were lost to mortal sight;
but the Dead followed them.          --"The Passing of the Grey Company"