フィルターのクリア

In between the years, a PISA question (nothing essential): The last digit of 7^190

4 ビュー (過去 30 日間)
Alexander
Alexander 2023 年 12 月 28 日
コメント済み: Alexander 2023 年 12 月 29 日
Last digit of 7^190, I thought a simple question if you have Matlab. But
fprintf('%f\n',7.0^190.0)
reports 4 as last digit, but it must be an odd number. 7^190 is fare away from realmax. Why that? It's not a big issue, only for my understanding.
  1 件のコメント
Stephen23
Stephen23 2023 年 12 月 28 日
編集済み: Stephen23 2023 年 12 月 28 日
"7^190 is fare away from realmax"
REALMAX is irrelevant.
The value is well above FLINTMAX (so, as the documentation states, your value is outside the range of consecutive integer values), so there is no expectation that your value will be represented accurately down to the ones:

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

採用された回答

Paul
Paul 2023 年 12 月 28 日
Well, if 7^190 is larger than realmax, then using double precison won't work to just try to compute it. You could try the Symbolic Math Toolbox. Or do some analysis and see the pattern in the last digit of 7^n for increments of n, and then figure out where the pattern would be for n == 190.
  16 件のコメント
Rik
Rik 2023 年 12 月 29 日
Though Steven is technically correct that realmax is the largest integer that can be represented by a double, stating this is not helpful, as people will misinterpret it. Realmax does represent an integer, but since multiple numbers will map to realmax, its uses are limited. If you want to guarantee the correct last digit, flintmax is the limit.
There have been efforts to implement the quad datatype in Matlab, though to my knowledge that didn't reach a practical state. That would push flintmax to 2^113-1 (if I understand it correctly). Still not enough for this question, but a lot better.
Alexander
Alexander 2023 年 12 月 29 日
Dear All, thank you very much for the many answeres which were helpful to understand this item. Also thank you for the link above and
Happy New Year

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by