summary refs log tree commit diff stats
path: root/python
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2020-12-10 17:14:50 +0100
committerMarkus Armbruster <armbru@redhat.com>2020-12-19 10:37:16 +0100
commit54addb01d8c2511ef96b0f0ca6b695d120dd8363 (patch)
treea8ac70074b5c5c0d8729898f309ef0cc20d73339 /python
parent7b205a7373c25db2f3680dee5a8c82e038135ec1 (diff)
downloadfocaccia-qemu-54addb01d8c2511ef96b0f0ca6b695d120dd8363.tar.gz
focaccia-qemu-54addb01d8c2511ef96b0f0ca6b695d120dd8363.zip
string-output-visitor: Fix to use sufficient precision
The string output visitor should serialize numbers so that the string
input visitor deserializes them back to the same number.  It fails to
do so.

print_type_number() uses format %f.  This is prone to nasty rounding
errors.  For instance, numbers between 0 and 0.0000005 get flushed to
zero.

We currently use this visitor only for HMP info migrate, info network,
info qtree, and info memdev.  No double values occur there as far as I
can tell.

Fix anyway by formatting with %.17g.  17 decimal digits always suffice
for IEEE double.

See also recent commit "qobject: Fix qnum_to_string() to use
sufficient precision".

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20201210161452.2813491-9-armbru@redhat.com>
Diffstat (limited to 'python')
0 files changed, 0 insertions, 0 deletions