Modulo of realmax in matlab

조회 수: 1 (최근 30일)
Mayank Bajpai
Mayank Bajpai 2020년 10월 31일
댓글: Ameer Hamza 2020년 10월 31일
I am getting the same results for the following:
mod(realmax,10^9 + 7) and mod(realmax-10000,10^9 + 7) or subtracting any other number from realmax.
What is the reason for this and how to resolve it?

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 10월 31일
MATLAB double datatype is based on IEEE-754 format: https://en.wikipedia.org/wiki/Double-precision_floating-point_format. This is a finite precision datatype, and you cannot represent all possible integer values accurately in this format.
flintmax
gives the maximum consecutive integer values, which can be accurately represented in this format. Above that, only a few integer values are precisely represented. In your case, realmax-10000 will just round off to realmax since double() data type does not have the precision to represent it.
  댓글 수: 2
Mayank Bajpai
Mayank Bajpai 2020년 10월 31일
Thanks. Got it :O
Ameer Hamza
Ameer Hamza 2020년 10월 31일
I am glad to be of help!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by