Possible Duplicate:
Why can't decimal numbers be represented exactly in binary?
Language c++ I'm declaring an array and i save numbers (type double) in it. Then i start comparing the difference between each two elements in the array. for example
a[1] = 0.05
a[2] = 0.1
a[3] = 0.15
so when i do the following
if(a[3] - a[2] == a[2] - a[1] )
the condition becomes false!!
After debugging, i found out that 0.05 is saved in the array as 0.0499......993 and the case is similar with 0.10 and 0.15
How can i overcome this problem?