MATLAB: Bug in single/double operations

castingeps('single')single/double

Can anybody explain this behaviour?
If you run the following code, it behaves as expected. You finish up with approximately eps('single')=1e-7.
HOWEVER, if you comment out the disp(x) line, then you finish up with eps('double')=1e-16.
Why should a disp(x) change anything? Is it a sneaky invisible casting?
————————————
format long
x = single(1) % single precision
while single(1+x) > 1 % keep going until no difference
x= x/2; % if you can tell any difference, half it.
disp(x) % comment this line out
end % while
---------------------------------------

Best Answer

This exact issue has already been discussed on the newsgroup, with the JIT being the likely cause of the difference: