How to generate a large integer from smaller integers?
2 views (last 30 days)
Show older comments
jalashree trivedi
on 27 Feb 2018
Commented: jalashree trivedi
on 28 Feb 2018
e.g {67,114,121} should yield a biginteger 4420217. also vice versa...4420217 should be converted back to {67,114,121}..some function similar to Mathematica function FromDigits[list,b]-takes the digits to be given in base b and constructs an integer from the list of its digits.
0 Comments
Accepted Answer
More Answers (1)
Walter Roberson
on 27 Feb 2018
Edited: Walter Roberson
on 27 Feb 2018
X = [67,114,121];
sum(X.*256.*(length(X)-1:-1:0))
3 Comments
Walter Roberson
on 27 Feb 2018
You can also use typecast to create the numbers but you have to pad with 0 before doing the typecast. You also need to swap the bytes after doing the typecast.
See Also
Categories
Find more on Numeric Types in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!