From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:59694) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SStvz-0005rB-8P for qemu-devel@nongnu.org; Fri, 11 May 2012 13:47:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SStvx-00047V-Cm for qemu-devel@nongnu.org; Fri, 11 May 2012 13:47:18 -0400 Received: from cantor2.suse.de ([195.135.220.15]:50482 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SStvx-00047P-2o for qemu-devel@nongnu.org; Fri, 11 May 2012 13:47:17 -0400 Message-ID: <4FAD509C.3020607@suse.de> Date: Fri, 11 May 2012 19:47:08 +0200 From: =?ISO-8859-1?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1335558083-26196-1-git-send-email-mdroth@linux.vnet.ibm.com> <1335558083-26196-5-git-send-email-mdroth@linux.vnet.ibm.com> <20120511133401.7599b6ba@doriath.home> <20120511173202.GB28865@illuin> In-Reply-To: <20120511173202.GB28865@illuin> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 4/7] qapi: String visitor, use %f represenation for floats List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael Roth Cc: pbonzini@redhat.com, aliguori@us.ibm.com, qemu-devel@nongnu.org, Luiz Capitulino Am 11.05.2012 19:32, schrieb Michael Roth: > On Fri, May 11, 2012 at 01:34:01PM -0300, Luiz Capitulino wrote: >> On Fri, 27 Apr 2012 15:21:20 -0500 >> Michael Roth wrote: >> >>> Currently string-output-visitor formats floats as %g, which is nice i= n >>> that trailing 0's are automatically truncated, but otherwise this cau= ses >>> some issues: >>> >>> - it 6 uses significant figures instead of 6 decimal places, which >>> means something like 155777.5 (which even has an exact floating po= int >>> representation) will be rounded to 155778 when converted to a stri= ng. >>> >>> - output will be presented in scientific notation when the normalize= d >>> form requires a 10^x multiplier. Not a huge deal, but arguably les= s >>> readable for command-line arguments. >>> >>> - due to using sig figs instead of hard-defined decimal places, it >>> fails a lot of the test-visitor-serialization unit tests for float= s. >>> >>> Instead, let's just use %f, which is what the QJSON and the QMP visit= ors >>> use. >>> >>> Signed-off-by: Michael Roth >>> --- >>> qapi/string-output-visitor.c | 2 +- >>> tests/test-string-output-visitor.c | 2 +- >>> 2 files changed, 2 insertions(+), 2 deletions(-) >>> >>> diff --git a/qapi/string-output-visitor.c b/qapi/string-output-visito= r.c >>> index 92b0305..34e525e 100644 >>> --- a/qapi/string-output-visitor.c >>> +++ b/qapi/string-output-visitor.c >>> @@ -52,7 +52,7 @@ static void print_type_number(Visitor *v, double *o= bj, const char *name, >>> Error **errp) >>> { >>> StringOutputVisitor *sov =3D DO_UPCAST(StringOutputVisitor, visi= tor, v); >>> - string_output_set(sov, g_strdup_printf("%g", *obj)); >>> + string_output_set(sov, g_strdup_printf("%f", *obj)); >> >> Doesn't look like a bug fix worth it for 1.1, am I wrong? >=20 > Well, object_property_print() is the only string-output-visitor user, > and it's not currently used. I don't see this changing for 1.1, so this > can probably wait. Actually it might be in 1.1: there's a pending patch by Paolo to use that for info qtree, where some properties were missing. My review comment has been resolved, so I will queue that patch for 1.1 and next. Andreas --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg