Working with numbers

What I learned from Code Complete

Be aware of overflow of numbers for intermediate results

Addition and subtraction on numbers with great magnitude in difference may not be accurate. 1000000+0.1 is not 1000000.1, may be 1000000.

Directly comparing floating number may not be accurate. One solution is to calculate the abs of two numbers and see if less than the acceptable range.

adding 0.1 to 0 ten times is not 1

Rounding error

Use integer instead float. For dollars and cents, you can store numbers in cents.