rounding-error
What class to use for money representation?
Never use a floating point number to represent money. Floating numbers do not represent numbers in decimal notation accurately. You would end with a nightmare of compound rounding errors, and unable to reliably convert between currencies. See Martin Fowler’s short essay on the subject. If you decide to write your own class, I recommend basing … Read more
How is floating point stored? When does it matter?
As mentioned, the Wikipedia article on IEEE 754 does a good job of showing how floating point numbers are stored on most systems. Now, here are some common gotchas: The biggest is that you almost never want to compare two floating point numbers for equality (or inequality). You’ll want to use greater than/less than comparisons … Read more