3 ms·
the question is [0, 1] so wouldn't that include +/-0 and 1, so 3 more?
by digga3000 10y ago
the question is [0, 1] so wouldn't that include +/-0 and 1, so 3 more?
- jacobolus 10y agoProbably shouldn’t include –0, which is used to represent underflow of negative numbers.
- nine_k 10y ago-0 is "below zero, but for so little that we cannot represent", so it's outside [0, 1].
- kr7 10y agoThough for the purposes of comparisons, -0 and +0 are the same in IEEE 754. So the expression "x >= 0.0f && x <= 1.0f" is true for x = -0.
- vog 10y agoWhy 3 more? Grandparent already counted one of the border points, so the correct number is either 1 more or 2 more, depending on whether you consider the floating point number -0 to be in the closed interval [0,1] or not. See my other posting for more details: https://news.ycombinator.com/item?id=13772578 https://news.ycombinator.com/item?id=13772578