diff options
Diffstat (limited to 'test/number.c')
-rw-r--r-- | test/number.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/test/number.c b/test/number.c index 1f4f9d9..46b2fda 100644 --- a/test/number.c +++ b/test/number.c @@ -129,7 +129,8 @@ void print_fixed(char *buf, size_t len, fixed f) { #define ABS(x) ((x) < 0 ? -(x) : (x)) uint32_t uintpart = FIXTOINT(ABS(f)); - uint32_t fracpart = ((ABS(f) & 0x3ff) * 1000) / (1 << 10); + /* + 500 to ensure round to nearest (division will truncate) */ + uint32_t fracpart = ((ABS(f) & 0x3ff) * 1000 + 500) / (1 << 10); #undef ABS size_t flen = 0; char tmp[20]; |