Why does NUM2STR function not honor the default format "%11.4g" in case of large numbers in MATLAB 7.0.4 (R14SP2)?

7 views (last 30 days)
When I invoke NUM2STR for very large numbers it does not honor the default format which is "%11.4g". Here is the code to reproduce this issue:
x =1e20/3;
num2str(x)
This produces an output:
33333333333333332000
where as the output should be
3.33e+19

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
This is an omission in the MATLAB 7.0.4 (R14SP2) documentation for NUM2STR. The documentation should read as follows:
" If the input array is integer-valued, NUM2STR returns the exact string
representation of that integer. The term integer-valued includes large
floating-point numbers that lose precision due to limitations of the hardware"
This has been corrected in the documentation.

More Answers (0)

Categories

Find more on Data Type Conversion in Help Center and File Exchange

Products


Release

R14SP2

Community Treasure Hunt

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

Start Hunting!