From: Luiz Capitulino <lcapitulino@redhat.com>
To: Michael Roth <mdroth@linux.vnet.ibm.com>
Cc: pbonzini@redhat.com, aliguori@us.ibm.com, qemu-devel@nongnu.org,
afaerber@suse.de
Subject: Re: [Qemu-devel] [PATCH 4/7] qapi: String visitor, use %f represenation for floats
Date: Fri, 11 May 2012 13:34:01 -0300 [thread overview]
Message-ID: <20120511133401.7599b6ba@doriath.home> (raw)
In-Reply-To: <1335558083-26196-5-git-send-email-mdroth@linux.vnet.ibm.com>
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?
> }
>
> char *string_output_get_string(StringOutputVisitor *sov)
> diff --git a/tests/test-string-output-visitor.c b/tests/test-string-output-visitor.c
> index 22909b8..608f14a 100644
> --- a/tests/test-string-output-visitor.c
> +++ b/tests/test-string-output-visitor.c
> @@ -84,7 +84,7 @@ static void test_visitor_out_number(TestOutputVisitorData *data,
>
> str = string_output_get_string(data->sov);
> g_assert(str != NULL);
> - g_assert_cmpstr(str, ==, "3.14");
> + g_assert_cmpstr(str, ==, "3.140000");
> g_free(str);
> }
>
next prev parent reply other threads:[~2012-05-11 16:36 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 ` Luiz Capitulino [this message]
2012-05-11 17:32 ` [Qemu-devel] [PATCH 4/7] qapi: String visitor, use %f represenation for floats Michael Roth
2012-05-11 17:47 ` Andreas Färber
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=20120511133401.7599b6ba@doriath.home \
--to=lcapitulino@redhat.com \
--cc=afaerber@suse.de \
--cc=aliguori@us.ibm.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).