long integers in matlab
9 views (last 30 days)
how can we do (simple) operations in Matlab with integers that exceed intmax("uint64")?
I am aware that in Python this is a posibility and there's virtually no limit for int size. In Python 3:
>> a = 10**100;
>> b = 10**100 + 1;
Is this possible in MATLAB as well? I am just curious so I can understand Matlab a bit better. I have no use case in mind
Stephen23 on 14 Jul 2022
Edited: Stephen23 on 14 Jul 2022
"what would be the recommended approach if I don't have access to Symbolic Math TB?"
You can download VPI by clicking on the big blue "DOWNLOAD" button in the top right corner:
unzipping it onto your MATLAB Search Path (e.g into the current directory), and then following its instructions.
More Answers (2)
Steven Lord on 14 Jul 2022
See Symbolic Math Toolbox.
ten = sym(10);
a = ten^100;
b = ten^100+1;
Note that performing the calculation then converting to a symbolic result won't work if the numbers get large enough. sym is perfectly happy to convert Inf to a symbolic value.
c1 = sym(10^500) % Already overflowed before sym was called
c2 = ten^500