Ah, okay. The reason is that using floor() (as we do, here and in the JS version of this function both) means that something like 3700ms would get rounded to 3 seconds, when it's actually closer to 4 seconds. So, by adding 500ms (or 0.5s) to the number, floor() ends up working like you'd expect with millisecond values between 500 and 999 above a given thousand.