3 ms·
Half-closed is generally good because it tends to reduce off-by-one errors. But this article overstates the case. Especially for floating-point, where the dist
by jmull 4y ago
Half-closed is generally good because it tends to reduce off-by-one errors.
But this article overstates the case. Especially for floating-point, where the distinction between a < b and a <= b is not straightforward. Some times you’re modeling closed intervals, and in that case using closed intervals is the right decision.
The “splitting by time” section should probably just be removed, since it confuses the point and doesn’t add anything. The scenario doesn’t really make sense (if you wanted this you’d store the registration time and get the hour you’d be better off by truncating the value, not using an interval). Also, if you’re going to be doing math on time values, you better know the precision of the values you’re working with (among many other things). Intervals, however closed or open aren’t going to help you there.
Maybe I shouldn’t criticize so much, since I agree with the general point. But this makes the case awkwardly.