I've noticed the calling num2str using a single but asking for up to 20 digits produces a lot more digits than should be stored with a single. These digits are not visible in the workspace but they are persistent; they are passed between functions and can be consistently recreated if you call the double function on the single. They do not represent the lost digits from the initial conversion to single, but running this script multiple times produces the same digits, even on different machines and versions.
What is really going on here? Is matlab really keeping track and moving these digits around, or are they somehow a function of the single precision number that is stored?
format long gy=1.234567890123456789 %only stores 1.23456789012346
x=single(y) %only stores 1.234568
num2str(x,20) %displays 1.2345678806304932
z=double(x); %stores 1.2345678806304932
num2str(z,20) %displays 1.2345678806304932
Best Answer