6 ms·
float32: 1 for exactly 1.0 (exponent=127,mantissa=0) + 127 * 2^23 for [0,1) (127 distinct exponent values (0 through 126) and any bit pattern in the mantissa; t
by mike_hock 4y ago
float32: 1 for exactly 1.0 (exponent=127,mantissa=0) + 127 * 2^23 for [0,1) (127 distinct exponent values (0 through 126) and any bit pattern in the mantissa; this includes +0 and denormals) + 1 for negative zero = 1065353218 = 0x3f800002 + 2, i.e. two more than the representation of 1.0, because everything up to and including that (as an unsigned integer) represents something in [0,1], plus the missing negative zero.
- pclmulqdq 4y agoOne could make an argument that negative zero is not in [0, 1]. Usually, negative zero is the result of operations like `(small negative number) / (big positive number)`, whose result at infinite precision would not be inside [0, 1]. Negative zero is equal to zero, though, so maybe it is inside [0, 1].
- mike_hock 4y ago[0,1] = {x | 0 <= x and x <= 1}. "<=" does not depend on where x came from or what it would have been had something else happened that didn't happen. There's no "maybe."
- pclmulqdq 4y agoAre we talking about the interval [0, 1] in R or about [0.0f, 1.0f] (the interval in the space of floats)? I'm pretty sure that your definition of an interval is correct even when the set doesn't have a total order, but if we're talking about floats whose values are in [0, 1] in the space of real numbers, that may not include -0.0f, since floating point numbers usually represent one number in a range of real values, and -0.0f represents -epsilon where epsilon is between 0 and the real value of the smallest denorm.
- mike_hock 4y ago> I'm pretty sure that your definition of an interval is correct even when the set doesn't have a total order Yes, and in the usual ordering on floats that's actually implemented by hardware, 0.0f == -0.0f, so -0.0f is in [-0.0f, 0.0f]. > since floating point numbers usually represent one number in a range of real values, and -0.0f represents -epsilon where epsilon is between 0 and the real value of the smallest denorm. That's a valid interpretation but apparently the standard ordering wasn't specified from that perspective.
- mike_hock 4y ago* I meant in [0.0f, 1.0f], of course
- mike_hock 4y ago* 0x3f800000 + 2, of course