From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N8wmt-00007m-0o for qemu-devel@nongnu.org; Fri, 13 Nov 2009 09:06:07 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N8wmo-00006z-Uy for qemu-devel@nongnu.org; Fri, 13 Nov 2009 09:06:06 -0500 Received: from [199.232.76.173] (port=57534 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N8wmo-00006o-NK for qemu-devel@nongnu.org; Fri, 13 Nov 2009 09:06:02 -0500 Received: from mail-bw0-f212.google.com ([209.85.218.212]:59412) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N8wmo-0005fL-8o for qemu-devel@nongnu.org; Fri, 13 Nov 2009 09:06:02 -0500 Received: by bwz4 with SMTP id 4so3665193bwz.2 for ; Fri, 13 Nov 2009 06:06:01 -0800 (PST) Message-ID: <4AFD67C4.9070100@codemonkey.ws> Date: Fri, 13 Nov 2009 08:05:56 -0600 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 3/3] Add test suite for json marshalling References: <1257967478-4847-1-git-send-email-aliguori@us.ibm.com> <1257967478-4847-3-git-send-email-aliguori@us.ibm.com> <20091113031431.GF19405@shareable.org> In-Reply-To: <20091113031431.GF19405@shareable.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jamie Lokier Cc: Anthony Liguori , qemu-devel@nongnu.org, Luiz Capitulino Jamie Lokier wrote: > Anthony Liguori wrote: > >> After checking that we can demarshal, marshal again and compared to >> the expected decoded value. This doesn't work so well for floats >> because they cannot be accurately represented in decimal but we try >> our best. >> > > Good sprintf/scanf/strtod implementations do guarantee that what's > printed and then parsed gets back the same floating point value, as > long as you have printed sufficient decimal digits. > > I'm not sure if FLT_DIG/DLB_DIG are the right number of digits, > though. Glibc's documentation of those is confusing and they might > mean something a little different. > Eh, I played around quite a bit and the results were disappointing. $ printf "%f\n" 43.32 43.320000 $ printf "%0.32f\n" 43.32 43.31999999999999999972244424384371 Regards, Anthony Liguori > -- Jamie > > >