Author: jmb
Date: Fri Jan 23 17:36:20 2009
New Revision: 6205

URL: http://source.netsurf-browser.org?rev=6205&view=rev
Log:
Ensure that we round the fractional part to nearest when converting back to 
decimal.

Modified:
    trunk/libcss/test/dump.h
    trunk/libcss/test/number.c

Modified: trunk/libcss/test/dump.h
URL: 
http://source.netsurf-browser.org/trunk/libcss/test/dump.h?rev=6205&r1=6204&r2=6205&view=diff
==============================================================================
--- trunk/libcss/test/dump.h (original)
+++ trunk/libcss/test/dump.h Fri Jan 23 17:36:20 2009
@@ -323,7 +323,8 @@
 {
 #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];

Modified: trunk/libcss/test/number.c
URL: 
http://source.netsurf-browser.org/trunk/libcss/test/number.c?rev=6205&r1=6204&r2=6205&view=diff
==============================================================================
--- trunk/libcss/test/number.c (original)
+++ trunk/libcss/test/number.c Fri Jan 23 17:36:20 2009
@@ -129,7 +129,8 @@
 {
 #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];


_______________________________________________
netsurf-commits mailing list
[email protected]
http://vlists.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org

Reply via email to