Why does 10^61 not equal 1e61 in MATLAB?
Show older comments
I noticed that 10^61==1e61 evaluates to false (0) in MATLAB. This implies that a^b and 1eX are computed differently. I am wondering how each one is computed, and why are they computed differently? In other words, why is 1eX not just computed as 10^X using the existing exponentiation function?
So far, I have figured out that 10^61-1e61==eps(1e61), meaning that 10^61 and 1e61 are adjacent floating point numbers, and that the true value is in between these two, and that 1e61 is closer than 10^61 to the true value. But I am not sure why they are different -- in other programming languages, like Python and even Octave, they are the same. But in MATLAB, they seem to be different?
Accepted Answer
More Answers (1)
>> for i=3:40, if 10^i~=eval(['1E' num2str(i)]),disp(i),break,end,end
29
>>
I may be wrong but I think most languages special-case the case 1^N; apparently Matlab doesn't.
Categories
Find more on MATLAB in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!