]> git.kaiwu.me - nginx.git/commitdiff
fix rounding issues in %f format
authorIgor Sysoev <igor@sysoev.ru>
Wed, 12 May 2010 13:13:11 +0000 (13:13 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Wed, 12 May 2010 13:13:11 +0000 (13:13 +0000)
src/core/ngx_string.c

index ce1fad65c616777e9717ccf785590b0bc96017e1..5cf505aa1550701d4cd600e7d05193f9225b6f7e 100644 (file)
@@ -386,7 +386,7 @@ ngx_vslprintf(u_char *buf, u_char *last, const char *fmt, va_list args)
                      * (int64_t) cast is required for msvc6:
                      * it can not convert uint64_t to double
                      */
-                    ui64 = (uint64_t) ((f - (int64_t) ui64) * scale);
+                    ui64 = (uint64_t) ((f - (int64_t) ui64) * scale + 0.5);
 
                     buf = ngx_sprintf_num(buf, last, ui64, '0', 0, frac_width);
                 }