MATLAB: How to generate a large integer from smaller integers

biginteger

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.

Best Answer

Pure math solution, no bit-bashing:
>> val = 4420217;
>> vec = fix(mod(val./256.^(floor(log2(val)/8):-1:0),256))
vec =
67 114 121
>> sum(vec.*256.^(numel(vec)-1:-1:0))
ans =
4420217