float numbers/ real numbers is much complicated than integers. the range of float needs to worry about more than upper and lower bound, but also minimum closet difference between any two consecutive float number.
Thomas Müller Grafsays:
I find it weird that 0.0 1 is out of range (not rounded to 0), but 1.0 1 is not out of range, and rounded instead to 1. The round-trip behavior might also be weird for numbers very close to (but not exactly) 0.
gcc 11.2 can parse 2.22507e-308, but a bit below that is out of range.
Your comment did not come out right. There is a formatting issue.
Thomas Müller Grafsays:
I find it weird that 0.0 (…400 times 0…) 1 is out of range (not rounded to 0), but 1.0 (…400 times 0…) 1 is not out of range, and rounded instead to 1.
The round-trip behavior might also be weird for numbers very close to (but not exactly) 0: I’m wondering if it will always work as expected if a number is first converted to a string, and then parsed again.
gcc 11.2 can parse 2.22507e-308, but a bit below that is out of range. This doesn’t match the bound you gave with of 4.94e-324.
Nicolassays:
It’s probably best to consider 64-bit floating point range to be from 1.1e-308 to 1.8e308, i.e. excluding denormal values. Including denormal numbers is problematic because of the loss of precision. Including numbers beyond that is pointless because they are not representable.
float numbers/ real numbers is much complicated than integers. the range of float needs to worry about more than upper and lower bound, but also minimum closet difference between any two consecutive float number.
I find it weird that 0.0 1 is out of range (not rounded to 0), but 1.0 1 is not out of range, and rounded instead to 1. The round-trip behavior might also be weird for numbers very close to (but not exactly) 0.
gcc 11.2 can parse 2.22507e-308, but a bit below that is out of range.
Your comment did not come out right. There is a formatting issue.
I find it weird that 0.0 (…400 times 0…) 1 is out of range (not rounded to 0), but 1.0 (…400 times 0…) 1 is not out of range, and rounded instead to 1.
The round-trip behavior might also be weird for numbers very close to (but not exactly) 0: I’m wondering if it will always work as expected if a number is first converted to a string, and then parsed again.
gcc 11.2 can parse 2.22507e-308, but a bit below that is out of range. This doesn’t match the bound you gave with of 4.94e-324.
It’s probably best to consider 64-bit floating point range to be from 1.1e-308 to 1.8e308, i.e. excluding denormal values. Including denormal numbers is problematic because of the loss of precision. Including numbers beyond that is pointless because they are not representable.
Surely, you want to include the two zeros as well as the negative numbers?
Sure that would make sense.
<>
How infinity could be inclusive?
just only going from the definition it is simply impossible.