On Thu, Nov 12, 2009 at 11:10 AM, Lidia Bressan
<address@hidden> wrote:
Sure, here I write all the information I was missing in the last email.
I use GNU Octave, version 3.2.2. I'm not sure what you mean with octave
configuration.
Any result:
octave:105> any ((1:0.05:5) == 2.05)
ans = 0
There you go. As you can see, something is wrong. I suppose the simpler equality
1 + 21 * 0.05 == 2.05
does not hold for you either (am I right)?
This is because numbers like 0.05 do not have an exact representation in the FP arithmetics. When you say 0.05, Octave actually picks the closest floating-point number, which is 3602879701896397 * 2^-56. Then, when it calculates 1 + 21 * 0.05 (and it does so even in the for loop), it uses this number, and the result is a tiny bit off.
Is there a way to go around a precision issue?