How can I print 64-bit hex numbers using the SPRINTF function?

44 views (last 30 days)
I would like to print large 64-bit hex numbers using the SPRINTF function
Executing the SPRINTF function results in the following:
sprintf('%x', 4294967296)
ans =
4.294967e+009
sprintf('%x', 4294967295)
ans =
ffffffff

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 25 Oct 2010
This enhancement has been incorporated in Release 2010b (R2010b). For previous product releases, read below for any possible workarounds:
The abillity to print 64-bit hex numbers using the SPRINTF function is not available in MATLAB.
To work around this issue, use the following command to print the numbers in hex format:
sprintf('%c', dec2hex(4294967296))
1. This would help you to print out the numbers which are greater than 2^32 in hex format.
2. However, you can only use the range from 0 to 2^52 as the DEC2HEX function gives unpredictable results for nonnegative numbers greater than 2^52. You will get the warning regarding the same in this case.

More Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!