Simplifying somewhat, floating point numbers are basically stored as a series of fractions of powers of 2. (1/2, 1/4, 1/8, 1/16, 1/32, 1/64, etc). If your number can be represented as the sum of some number of those, you are lucky — for most numbers (1/3, 1/5, etc) you get a pretty close approximation. Comparing floating point numbers for exact equality is fraught with peril.
2
solved Unexpected behavior of floating point numbers in C [duplicate]