by malloc47 on 9/3/12, 5:53 PM with 2 comments
by lutusp on 9/3/12, 6:16 PM
Those interested in serious computer mathematics have remedies -- instead of floating-point values, use integers or ratios where possible, as Sage (http://www.sagemath.org/) does. In Sage, one discovers that 3456/7263 times 21/996 equals 224/22327, rather than 0.010032695839118555, as one might expect from less specialized programming environments.
Or one can increase the size of floating-point mantissas, something not possible in a non-specialized programming environment, but always available in environments designed for serious mathematics. This is less satisfactory than avoiding floating-point altogether, of course.
To the student programmer, this simple advice -- always prefer integers over floating-point values, and never use a floating-point value as a loop index.
by pwg on 9/3/12, 10:08 PM
What Every Computer Scientist Should Know About Floating-Point Arithmetic
http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.ht...