As Jon Skeet says in a comment, the problem is - to put it bluntly - your understanding of floats. A float uses just 32 bits to store a binary floating point value which must be converted to decimal values. This results in "weird" values like you are experiencing.
The simplest fix is often to just use doubles. But please do read up on floats and why they don't represent base 10 numbers too well.