Windows: Fix rounding error when calculating now_us

Improve accuracy of time calculations and avoid division by zero when
ticksPerSecond.QuadPart < 1000000.
This commit is contained in:
Duane Littleton 2013-02-27 13:53:07 -05:00
parent 22d9d95dd2
commit 1e52a451d6

View File

@ -66,7 +66,7 @@ uint64_t zmq::clock_t::now_us ()
// Convert the tick number into the number of seconds
// since the system was started.
double ticks_div = (double) (ticksPerSecond.QuadPart / 1000000);
double ticks_div = ticksPerSecond.QuadPart / 1000000.0;
return (uint64_t) (tick.QuadPart / ticks_div);
#elif defined HAVE_CLOCK_GETTIME && defined CLOCK_MONOTONIC