Why is it that when I put this equation in matlab it equals 0 but when I do (2^52+1) -2^52 it gives me 1, aren't they the same equation. I think I kind of understand how 64bit float can't represent odd numbers past 2^53-1 but these numbers are not even close to that
Asked
Active
Viewed 79 times
0
-
2Using python's decimal module you can see that `sqrt(2^52 +1)` has a decimal expansion that begins `67108864.00000000745`. There isn't enough precision in a 52-bit mantissa to hold that. The decimal part is lopped off entirely. – John Coleman Nov 08 '21 at 21:46
-
1so does that mean the computer is able to hold the value 2^52+1 exactly but isnt able to hold sqrt(2^52+1) exactly? – cantcode22 Nov 08 '21 at 22:32
1 Answers
2
There are 2^52
double precision numbers between 2^52
and 2^53-1
which the sqrt
function maps to (approximately) the interval [2^26, sqrt(2)*2^26]
. The latter contains just 2^52/sqrt(2)
numbers, which means a lot of numbers x
must map to the same sqrt(x)
.

chtz
- 17,329
- 4
- 26
- 56