Float values will pretty much always be slightly off due to how they are stored internally, plus the impossibility to actually store every conceivable value between 0 and 1, as there are an infinite number of values within that range. For example, it is impossible to store EXACTLY 1/3, as the decimal equivalent is 1.33 recurring, forever!
If you require greater accuracy you can use Double's instead, but these too have their limit.
As mentioned, the slight differences are due to how floats/doubles are stored, but I'm no expert on the format of them when stored internally, so maybe someone else can explain it a bit better than I can!
If you require greater accuracy you can use Double's instead, but these too have their limit.
As mentioned, the slight differences are due to how floats/doubles are stored, but I'm no expert on the format of them when stored internally, so maybe someone else can explain it a bit better than I can!