How do I convert from HEX to DEC numbers larger than 2^52?
Show older comments
The MATLAB function "hex2dec" has a input limit of 2^52, how do you convert numbers larger than 2^52 from HEX to DEC in MATLAB?
Accepted Answer
More Answers (1)
If the number is larger than 2^52 then if it is an integer it needs to be either int64 or uint64.
H = '400921fb54442d18';
D = sscanf(H, '%lx')
dec2hex(D)
num2hex(pi)
Dd = typecast(D, 'double')
Dd - pi
We see we bit-for-bit reconstruction
If the value is intended to be int64 instead of uint64, then use the %lx format to get uint64 and then typecast() that to int64
Categories
Find more on Common Operations 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!