After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 706318 - rounding error in stopwatch
rounding error in stopwatch
Status: RESOLVED FIXED
Product: gnome-clocks
Classification: Applications
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Clocks maintainer(s)
Clocks maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2013-08-19 15:19 UTC by Alessandro Campagni
Modified: 2013-08-24 11:44 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
tentative patch (3.82 KB, patch)
2013-08-19 16:25 UTC, Alessandro Campagni
none Details | Review

Description Alessandro Campagni 2013-08-19 15:19:35 UTC
elapsed time and lap time doesn't always agree, for instance in [1] we can see that according to lap#18 time and elapsed time at lap#17 we should have elapsed time 01:40:11 instead of 01:40:12

This problem is not due to the rounding policy, indeed if we have

lap#n      elapsed time: 5.146, lap time: 3.362 
lap#(n+1)  elapsed time: 9.304, lap time: 4.158

we're going to have problems using both ceil or floor.

[1] https://www.dropbox.com/s/rojplhcvamvtwmh/Screenshot%20from%202013-08-19%2013%3A45%3A09.png
Comment 1 Alessandro Campagni 2013-08-19 16:25:39 UTC
Created attachment 252256 [details] [review]
tentative patch
Comment 2 Alessandro Campagni 2013-08-19 16:26:23 UTC
(In reply to comment #1)
> Created an attachment (id=252256) [details] [review]
> tentative patch

tentative patch, saving the time information with four integers let us round one time only.

By the way I believe that the code I added in utils.vala could be an example of how not to write code :)
Maybe we could use two arrays for the time information, for instance:
minuend[h] instead of m_h
minuend[m]] instead of m_m
subtrahend[c] instead of s_s
and so on...
I mean I really don't like the code I wrote, I would be happy to ear some hints to make it more neat
Comment 3 Paolo Borelli 2013-08-24 09:51:47 UTC
I fixed this in a simpler way in

https://git.gnome.org/browse/gnome-clocks/commit/?id=b5059d963c1f1d3fd4ef3c612eedaa8ea540a752


Please double check my naive approach is not buggy :)
Comment 4 Alessandro Campagni 2013-08-24 11:44:25 UTC
I really like your solution :)