On Dec 4, 2014, at 09:58 , Masamichi HOSODA <truer...@sea.plala.or.jp> wrote: > >> Also, the mention of optimization reminds me of one of the horrors of >> floating point types: a value in a register can quietly be changed when it >> is written to memory. Take a look at some of the “myths” in section 1 of >> https://hal.archives-ouvertes.fr/hal-00128124/en/ . […] > I think that floating point can be used as long as it's used correct. > > operator== shouldn't be used for comparison of floating point values. > operator!= shouldn't be used too. > operator< and operator> may be used.
The issue is more complex than that. Sit down and try this: #include <iostream> int main(void) { double a = 0; double b = 0; std::cin >> a; std::cin >> b; double x = a/b; if (x < a/b) { std::cout << "x:" << x << " < " << (a/b) << std::endl; } volatile double y = x; if (y < a/b) { std::cout << "y:" << y << " < " << (a/b) << std::endl; } return 0; } Results in LilyDev 3: $ g++ fp.cc -o fp && (echo "2 3" | ./fp) x:0.666667 < 0.666667 y:0.666667 < 0.666667 $ g++ -O3 fp.cc -o fp && (echo "2 3" | ./fp) y:0.666667 < 0.666667 Add looping and you’ve got fatal issues. (And if you’re like me, steam will erupt from your ears any second now...) — Dan _______________________________________________ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel