From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:39211) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOViA-00061v-NG for qemu-devel@nongnu.org; Mon, 23 May 2011 10:02:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QOVi9-0001na-Lj for qemu-devel@nongnu.org; Mon, 23 May 2011 10:02:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8246) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOVi9-0001n5-ET for qemu-devel@nongnu.org; Mon, 23 May 2011 10:02:21 -0400 Date: Mon, 23 May 2011 11:02:16 -0300 From: Luiz Capitulino Message-ID: <20110523110216.751853fc@doriath> In-Reply-To: <4DDA663F.30907@codemonkey.ws> References: <20110520180331.GA21837@amd.home.annexia.org> <4DD6AEB9.6060506@codemonkey.ws> <20110523130411.GR24143@redhat.com> <4DDA620F.1090308@codemonkey.ws> <20110523134021.GT24143@redhat.com> <4DDA663F.30907@codemonkey.ws> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] qemu: json: Fix parsing of integers >= 0x8000000000000000 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: qemu-devel@nongnu.org, "Richard W.M. Jones" On Mon, 23 May 2011 08:50:55 -0500 Anthony Liguori wrote: > >> The actual value of the alert will surprise you :-) > >> > >> Integers in Javascript are actually represented as doubles > >> internally which means that integer constants are only accurate up > >> to 52 bits. > >> > >> So really, we should cap integers at 32-bit :-/ > >> > >> Have I mentioned recently that I really dislike JSON... > > > > NB, I am distinguishing between JSON the generic specification and > > JSON as implemented in web browsers. JSON the specification has *no* > > limitation on integers. > > The spec has no notion of integers at all. Here's the relevant text. > Note that the BNF only has a single entry point for numbers. It does > not distinguish between integers and floating point numbers. Also, the > only discussion of valid numbers is about whether the number can be > represented as a rational number. I think the only way to read the spec > here is that *all* numbers are meant to be represented as floating point > numbers. Python json works just fine: >>> import json >>> json.dumps(9223372036854775807) '9223372036854775807' >>> json.loads('9223372036854775807') 9223372036854775807