on the meaning of doubles ...

1 次查看(过去 30 天)
I have copy pasted below a piece from MATLAB documentation.
Numbers represented in the double format have a maximum precision of 52 bits. Any double requiring more bits than 52 loses some precision. For example, the following code shows two unequal values to be equal because they are both truncated: x = 36028797018963968; y = 36028797018963972; x == y ans = 1
Integers have available precisions of 8-bit, 16-bit, 32-bit, and 64-bit. Storing the same numbers as 64-bit integers preserves precision: x = uint64(36028797018963968); y = uint64(36028797018963972); x == y ans = 0
My question is this.
>> 2^52
ans =
4503599627370496
If you use double for any numbers greater than 2^52 as above, loss of precision and similar problem like in the documentation should occur. I checked but it does not occur as shown as below. Why?
x =
4503599627370500
y =
4503599627370501
x==y
ans =
0

采纳的回答

dpb
dpb 2014-7-19
Actually, IEEE-754 is 53 bit mantissa. For all the gory details see...

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Multidimensional Arrays 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by