aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2014-02-08 11:01:57 +0100
committerAndreas Färber <afaerber@suse.de>2014-02-14 21:12:05 +0100
commite41b509d68afb1f329c8558b6edfe2fcbac88e66 (patch)
tree3885701adcfc6f88b28cec652e52c8a95517887f /tests
parent85ca1202d1227b3a816c714db6c8e19b613172c5 (diff)
qapi: Refine human printing of sizes
This fixes several bugs or shortcomings of the previous pretty-printer. In particular: * use PRIu64 instead of casting to long long * the exact value is included too * the correct unit of measure (MiB, GiB, etc.) is used. PiB and EiB are added too. * due to an off-by-one error, 512*2^30 was printed as 0.500MiB rather than 512MiB. floor(log2(val)) is equal to 63 - clz(val), while the code used 64. * The desired specification is %g rather than %f, which always uses three decimals in the current code. However %g would switch to scientific notation when the integer part is >= 1000 (e.g. 1000*2^30). To keep the code simple, switch to the higher power when the integer part is >= 1000; overflow is avoided by using frexp instead of clz. Suggested-by: Eric Blake <eblake@redhat.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'tests')
0 files changed, 0 insertions, 0 deletions