Currently the rounding logic is slightly broken. For instance, in the unit tests, 95543ms, ie. 1 min 35 sec 543 ms rounded to 3 second decimal digits with colonNotation=true yields 1:35.580 (this should obviously be 1:35.543). I also propose that time rounding should always floor the value, not regular rounding up when the remainder is >=0.5, as otherwise the the interval between 1-2 seconds will only be 0.5 seconds long, as it is rounded to 2 seconds after as time passes 1500 ms.
This PR changes rounding so that it always rounds down. For example, with zero second precision, 1999 ms is 1 second, not 2 seconds. A new flooring function is introduced that adds an epsilon term prior to flooring to avoid floating point errors, which replaces the current logic. Without it, one the verbose unit tests for 5254ms rounded to 4 second decimal places would yield 5.2539 seconds, not 5.2540 seconds).
Currently the rounding logic is slightly broken. For instance, in the unit tests,
95543ms
, ie.1 min 35 sec 543 ms
rounded to 3 second decimal digits withcolonNotation=true
yields1:35.580
(this should obviously be1:35.543
). I also propose that time rounding should always floor the value, not regular rounding up when the remainder is>=0.5
, as otherwise the the interval between 1-2 seconds will only be 0.5 seconds long, as it is rounded to 2 seconds after as time passes 1500 ms.This PR changes rounding so that it always rounds down. For example, with zero second precision,
1999 ms
is 1 second, not 2 seconds. A new flooring function is introduced that adds an epsilon term prior to flooring to avoid floating point errors, which replaces the current logic. Without it, one the verbose unit tests for5254ms
rounded to 4 second decimal places would yield5.2539 seconds
, not5.2540 seconds
).