From: "Andreas Färber" <afaerber@suse.de>
To: Michael Roth <mdroth@linux.vnet.ibm.com>
Cc: pbonzini@redhat.com, aliguori@us.ibm.com, qemu-devel@nongnu.org,
Luiz Capitulino <lcapitulino@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 4/7] qapi: String visitor, use %f represenation for floats
Date: Fri, 11 May 2012 19:47:08 +0200 [thread overview]
Message-ID: <4FAD509C.3020607@suse.de> (raw)
In-Reply-To: <20120511173202.GB28865@illuin>
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 <mdroth@linux.vnet.ibm.com> wrote:
>>
>>> Currently string-output-visitor formats floats as %g, which is nice in
>>> that trailing 0's are automatically truncated, but otherwise this causes
>>> some issues:
>>>
>>> - it 6 uses significant figures instead of 6 decimal places, which
>>> means something like 155777.5 (which even has an exact floating point
>>> representation) will be rounded to 155778 when converted to a string.
>>>
>>> - output will be presented in scientific notation when the normalized
>>> form requires a 10^x multiplier. Not a huge deal, but arguably less
>>> 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 floats.
>>>
>>> Instead, let's just use %f, which is what the QJSON and the QMP visitors
>>> use.
>>>
>>> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
>>> ---
>>> 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-visitor.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 *obj, const char *name,
>>> Error **errp)
>>> {
>>> StringOutputVisitor *sov = DO_UPCAST(StringOutputVisitor, visitor, 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?
>
> 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
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
prev parent reply other threads:[~2012-05-11 17:47 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1335558083-26196-1-git-send-email-mdroth@linux.vnet.ibm.com>
[not found] ` <1335558083-26196-2-git-send-email-mdroth@linux.vnet.ibm.com>
2012-05-01 21:37 ` [Qemu-devel] [PATCH 1/7] qapi: add Visitor interfaces for uint*_t and int*_t Andreas Färber
[not found] ` <1335558083-26196-7-git-send-email-mdroth@linux.vnet.ibm.com>
2012-05-01 21:52 ` [Qemu-devel] [PATCH 6/7] qdev: use int32_t container for devfn property Andreas Färber
[not found] ` <1335558083-26196-8-git-send-email-mdroth@linux.vnet.ibm.com>
2012-05-01 21:54 ` [Qemu-devel] [PATCH 7/7] qdev: switch property accessors to fixed-width visitor interfaces Andreas Färber
2012-05-01 22:02 ` [Qemu-devel] [PATCH v5 0/7] add fixed-width visitors and serialization tests/fixes Andreas Färber
2012-05-11 1:22 ` Andreas Färber
2012-05-11 15:19 ` Michael Roth
[not found] ` <1335558083-26196-3-git-send-email-mdroth@linux.vnet.ibm.com>
2012-05-11 16:22 ` [Qemu-devel] [PATCH 2/7] qapi: QMP input visitor, handle floats parsed as ints Luiz Capitulino
2012-05-11 17:04 ` Michael Roth
2012-05-11 17:16 ` Andreas Färber
2012-05-11 17:34 ` Michael Roth
2012-05-11 17:38 ` Luiz Capitulino
[not found] ` <1335558083-26196-5-git-send-email-mdroth@linux.vnet.ibm.com>
2012-05-11 16:34 ` [Qemu-devel] [PATCH 4/7] qapi: String visitor, use %f represenation for floats Luiz Capitulino
2012-05-11 17:32 ` Michael Roth
2012-05-11 17:47 ` Andreas Färber [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4FAD509C.3020607@suse.de \
--to=afaerber@suse.de \
--cc=aliguori@us.ibm.com \
--cc=lcapitulino@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).