projects
/
platform
/
upstream
/
xorg-server.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
509b3c3
)
os: Round fraction in pnprintf %f format
author
Keith Packard
<keithp@keithp.com>
Fri, 8 Feb 2013 16:57:43 +0000
(08:57 -0800)
committer
Keith Packard
<keithp@keithp.com>
Fri, 8 Feb 2013 16:57:43 +0000
(08:57 -0800)
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>
os/utils.c
patch
|
blob
|
history
diff --git
a/os/utils.c
b/os/utils.c
index
3ba6499
..
60e828e
100644
(file)
--- 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 */