Computers can represent only a finite number of digits. It is therefore impossible to precisely represent repeating binary sequences of floating point numbers. This includes many finite decimal numbers, such as 1/10 which have repeating binary representations.
When precise computation is necessary, and especially when doing currency calculations, consider alternative representations that may be able to completely represent values rather than the floating point representations float
and double
.
...