why does realmax('single') display 8 digits?

3 ビュー (過去 30 日間)
Sean Doherty
Sean Doherty 2020 年 12 月 17 日
コメント済み: Sean Doherty 2020 年 12 月 18 日
most texts agree that IEEE-754 sinlge persision has 7 signicant digits and double percision has 15
so why does realmax('single') display 8 digits and realmax('double') display 16 digits?
  8 件のコメント
Sean Doherty
Sean Doherty 2020 年 12 月 18 日
thanks
Sean Doherty
Sean Doherty 2020 年 12 月 18 日
Thakyou Stephen. This clarifies things. I would have accepted your answer, but not offered that option

サインインしてコメントする。

回答 (2 件)

Ameer Hamza
Ameer Hamza 2020 年 12 月 17 日
編集済み: Ameer Hamza 2020 年 12 月 17 日
"most texts agree that IEEE-754 sinlge persision has 7 signicant digits and double percision has 15"
But they don't. More precisely, they have 24 and 53 significant binary digits, respectively. Both are capable of representing 2^24 and 2^53 consecutive integers without any loss of precision. MATLAB just returns these values.
Note that it is still possible to represent even bigger integers with full precision, but the only issue is that the number adjacent to them cannot be represented precisely.
Read here: https://en.wikipedia.org/wiki/IEEE_754#Basic_and_interchange_formats. They are capable of representing ~7.22 and ~15.96 decimal digits respectively.
  12 件のコメント
Bruno Luong
Bruno Luong 2020 年 12 月 17 日
編集済み: Bruno Luong 2020 年 12 月 17 日
"but there are others where 8 digits decimal is required."
Like
flintmax('single')
Other one need 17 digits in my example of 2^(-24) or even more (up to 20 digits).
Limiting about 7-8 digits is just like see only the emerging side of an ice-berg, and pretend digits after the 8th are not significant is just plain wrong, at least from my point of view.
Walter Roberson
Walter Roberson 2020 年 12 月 17 日
Given N digits of a single precision number, is entering those N digits enough to exactly reproduce the same bit pattern?
fprintf('%1.20e\n', single(5.960464e-8))
5.96046412226769461995e-08
fprintf('%1.20e\n', single(5.9604644e-8))
5.96046447753906250000e-08
So 7 input digits is not enough to completely preproduce 2^-24 but 8 input digits is. Therefor, this particular number has 8 significant decimal digits in single precision. But there are other values that use "all" of the digits (no trailing 0 in decimal) that 7 copied digits is enough.

サインインしてコメントする。


Walter Roberson
Walter Roberson 2020 年 12 月 17 日
>> flintmax('single')
ans =
single
16777216
You get 7 full digits, up to 9999999 . And there is some spare room beyond that, but not enough for a full digit. It is about 7.22 digits.

カテゴリ

Help Center および File ExchangeNumeric Types についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by