Reputation: 111
If I make a single precision operation with the values, it will give a result ending with 8:
>> single(single(6.500001e+02)*single(-64.1775131)*single(0.65)*single(2))
ans = -5.4230008e+004
Then I make any operation using double precision, and the same operation as before, using single precision, the result will be different from the first time I run it:
>> double(6.5000012e+02)*double(-64.1775131)*double(0.65)*double(2)
ans = -5.423000858119204e+004
>> single(single(6.500001e+02)*single(-64.1775131)*single(0.65)*single(2))
ans = -5.4230004e+004
This problem happens in Matlab 2008a 32 bits. This is not a problem in Matlab 2012b 64 bits.
Any thoughts on how to avoid this problem?
Thank you.
Upvotes: 5
Views: 137
Reputation:
I could not test but, from what I could find on MATLAB Central, it seems to be a bug in the Global Workspace @versions R2008*. So, to avoid the problem:
Upvotes: 2