I have a float holding a very important value, which has to be VERY exact.
The problem I have is I\'m changing the value of the float ALWAYS only + and - (No divisi
Just like an int
variable can only hold integers in a certain range, a float
can only hold certain values. 0.05
is not one of them.
If you set an int
variable to (say) 3.4, it won't actually hold the value 3.4; it will hold that value converted to a representable int
value: 3.
Similarly, if you set a float
variable to 0.05
, it won't get that exact value; it will instead get that value converted to the closest value representable as a float
. This is what you are seeing.