diff options
author | Keith Packard <keithp@keithp.com> | 2013-02-08 08:57:43 -0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2013-02-08 08:57:43 -0800 |
commit | b173eb2ae3349c557db1ff9e424fa540b8289bb2 (patch) | |
tree | 5e87b686286364541370f9a95d8f60d1a9926142 /os | |
parent | 509b3c3dc82e7abce1900d5e1cddd90f23be5a87 (diff) |
os: Round fraction in pnprintf %f format
Truncating the fraction part leads to a test failure where -1203.30 is
printed as -1203.29. Round this to the nearest value instead by adding
0.5 before converting to an integer
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'os')
-rw-r--r-- | os/utils.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/os/utils.c b/os/utils.c index 3ba6499c4..60e828e28 100644 --- a/os/utils.c +++ b/os/utils.c @@ -1999,7 +1999,7 @@ FormatDouble(double dbl, char *string) int slen = 0; uint64_t frac; - frac = (dbl > 0 ? dbl : -dbl) * 100.0; + frac = (dbl > 0 ? dbl : -dbl) * 100.0 + 0.5; frac %= 100; /* write decimal part to string */ |