From 173bbb754f53e8bfc8e4d488f2ed66fe1072ed69 Mon Sep 17 00:00:00 2001 From: Michael Roth Date: Mon, 30 Apr 2012 09:33:30 -0500 Subject: qapi: String visitor, use %f representation for floats MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 uses 6 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 scientific notation for numbers requiring more than 6 significant figures, 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 Signed-off-by: Andreas Färber --- tests/test-string-output-visitor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test-string-output-visitor.c') 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); } -- cgit v1.1