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

14 Ansichten (letzte 30 Tage)
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

Akzeptierte Antwort

MathWorks Support Team
MathWorks Support Team am 25 Okt. 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.

Weitere Antworten (0)

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by