3snowp7im / urn

Split tracker / timer with GTK+ frontend
GNU General Public License v3.0
126 stars 36 forks source link

After 17:45.98 comes 17:45.00, expected 17:46.00 or 17:45.99 #25

Closed SimonN closed 7 years ago

SimonN commented 7 years ago

Archlinux, urn-gtk build from github commit 4bc9b9f (March 2016, which is still the most recent commit in December 2016.)

This happenend during a livestream, here's the 1-minute highlight of the oddity: https://www.twitch.tv/simonnaar/v/107777423

This run was slower than the PB of 17:45.46 by 0.54 seconds. The "Boss 9" split is +0.54, which is correct. The total time for the run (that was slower than the PB) is displayed as 17:45.00. But that's not correct, it should be about 1 second slower: Either 17:45.99 or 17:46.00.

Looks like a misrounding? I haven't checked the urn source.

SimonN commented 7 years ago

I believe it's a misrounding of the subseconds, which urn tracks as integer microseconds (6 digits after dot). To display the subseconds, urn uses sprintf on the time converted to a double, rounding the subseconds two decimal places. Then it cuts off the part in front of the decimal dot, assuming it's a zero.

Since sprintf uses banker's rounding, 0.999 becomes 1.00, therefore 17:45.999000 is shown as 17:45.00. The 17:45 is rounded properly with integer division, which acts like floor, but the .00 part is really 1.00 with the 1 cut off.

I'm preparing a pull request. :-)