Floats (fractions and decimals) are only approximations. It is not possible to represent some of them with complete accuracy within the limits of finite binary storage.
In many cases, scaled integers are a better alternative. For example, when dealing with money/dollars, work with pennies and convert to dollars and cents for display using a simple division/modulus function.
Floats (fractions and decimals) are only approximations. It is not possible to represent some of them with complete accuracy within the limits of finite binary storage.
In many cases, scaled integers are a better alternative. For example, when dealing with money/dollars, work with pennies and convert to dollars and cents for display using a simple division/modulus function.