comparison src/core/ngx_string.c @ 3507:76fc7ad463cb

fix rounding issues in %f format
author Igor Sysoev <igor@sysoev.ru>
date Wed, 12 May 2010 13:13:11 +0000
parents c3fa65192119
children 098100f5f54b
comparison
equal deleted inserted replaced
3506:c3fa65192119 3507:76fc7ad463cb
384 384
385 /* 385 /*
386 * (int64_t) cast is required for msvc6: 386 * (int64_t) cast is required for msvc6:
387 * it can not convert uint64_t to double 387 * it can not convert uint64_t to double
388 */ 388 */
389 ui64 = (uint64_t) ((f - (int64_t) ui64) * scale); 389 ui64 = (uint64_t) ((f - (int64_t) ui64) * scale + 0.5);
390 390
391 buf = ngx_sprintf_num(buf, last, ui64, '0', 0, frac_width); 391 buf = ngx_sprintf_num(buf, last, ui64, '0', 0, frac_width);
392 } 392 }
393 393
394 fmt++; 394 fmt++;