4 ms·
> Milliseconds are converted to seconds by dividing by 1000 and rounding down like so It seems like the simpler explanation is that the iPhone actually rounds
by sokoloff 6y ago
> Milliseconds are converted to seconds by dividing by 1000 and rounding down like so
It seems like the simpler explanation is that the iPhone actually rounds to the closest integer rather than rounding down. (Whether they do this invisibly by adding 0.5s and rounding down is an implementation detail.)
- jiofih 6y agoThe sentence quoted is for the first example in the post, not the iPhone timer. That’s most likely what it does indeed, much more elegant than keeping track of the extra 500ms.
- sokoloff 6y agoI realize that. It seems like the entire blog post could be summarized as "I thought about doing something this way and when it didn't give me what I and everyone else expects out of a timer, my mental model adjusted to conclude that Apple was doing some weird gymnastics involving adding 500ms to some of their timer code and using Math.floor() but not to the time the timer actually goes off rather than adjusting my mental model to match the simpler way that humans expect rounding to work in a timer using [the equivalent of] Math.round()."
- deleted 6y ago[deleted]
- tobr 6y agoAgreed, to my eyes it seems clear that the display shows both “5” and “0” for half a second, which means the total duration is still 5 seconds, not 5.5 seconds.
- throwaway2245 6y agoCorrectly rounding to the nearest second is exactly the behaviour that I expect from a timer. It's not "fake".
- londons_explore 6y agoUnless you pause it... In which case it rounds up...
- furyofantares 6y agoOnly at 0:00. That's a separate feature, showing 0:01 at a minimum for a paused timer (presumably to make it very clear that you aren't looking at an expired timer, even though the UI disappears for an expired timer.)
- throwaway2245 6y agoAh. I see that my Apple app does do that, but it's not my preference. I would much prefer "0 seconds remaining" to mean 0 to 0.5 seconds remaining, than any other possible case. I would find it much easier to parse. (Alternatively, please show more accuracy for this case, where it's likely relevant)
- deleted 6y ago[deleted]
- buzzerbetrayed 6y agoExactly. Seems like the author is suggesting a timer with 4.9 seconds left should tell you it has 4 seconds left instead of 5. Not sure why anyone would think this. The tidbit about it displaying 1 even if there is 0.01 left is interesting though. Makes sense.
- asddubs 6y agoreddit works like this if you get downvoted and only get to post every 10 minutes. it tells you you have to wait 1 more minute, and then a minute later it tells you you have to wait 59 more seconds, very counterintuitive. gets me every time when I have a post typed out and it's putting me on timeout for going against the grain (like e.g. suggesting that mob justice is bad)