Dec 7, 2013

[C++][NOTE] Floating point maths is not associative.

Be aware of floating point optimizations introduced by constant folding in conformant code Use this:
 
define PI 3.1415
 
double torad2(double n) {
    return 180 / PI * n;
}
Not this:
 
define PI 3.1415
 
double torad1(double n) {
    return n * 180 / PI;
}
gcc Optimize Options

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.