From c227f663b6285f9caa19df72baaeaa7d89cebfc7 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Fri, 23 Jan 2009 23:36:20 +0000 Subject: Ensure that we round the fractional part to nearest when converting back to decimal. svn path=/trunk/libcss/; revision=6205 --- test/dump.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test/dump.h') diff --git a/test/dump.h b/test/dump.h index 6bff4aa..1adfbe6 100644 --- a/test/dump.h +++ b/test/dump.h @@ -323,7 +323,8 @@ static void dump_fixed(fixed f, char **ptr) { #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]; -- cgit v1.2.3