I'm dealing with arbitrarily large numbers in MATLAB, I've been futzing with a script for a while and finally found out that my problem wasn't a logic error.
It was this:
>> 2^63 - 1 == 2^63
ans =
1
In MATLAB 2012a, without additional libraries, is there a way to handle large numbers of up to 2^100
?
Edit:
Apparently, the precision error happens as soon as 2^54
.
Second Edit:
According to Peter, I can use vpa
. This actually solves the problem quite nicely:
>> vpa(sym(2^63)) - vpa(sym(2^63) - 1)
ans =
1.0