I'm not sure what's going on (seems like maybe a fast but error prone floating point rounding), but comparing the optimization flags enabled between -O0 and -O2 might help shed some light on it. You can get the explicit optimization flags enabled for your compiler via: g++ -Q -O2 --help=optimizers g++ -Q -O0 --help=optimizers Regards, Nate On Fri, Mar 2, 2018 at 10:17 AM, Tim van Erven via Boost-users < boost-users@lists.boost.org> wrote:
Dear all,
I am trying to understand why I am getting different numerical results with the interval library depending on the optimization level of the compiler.
I am attaching the smallest example I have been able to create:
# On my Mac laptop Apple LLVM version 9.0.0 (clang-900.0.39.2) boost 1.66 (installed via homebrew) $ g++ foo.cpp -o foo $ ./foo third1 = 0.333333333333333314829616256247390992939472198486328125000000 0000 third2 = 0.333333333333333314829616256247390992939472198486328125000000 0000 v1 = (0.999999999999999888977697537484345957636833190917968750000000 0000,1.0000000000000000000000000000000000000000000000000000000000000000) v2 = (0.999999999999999888977697537484345957636833190917968750000000 0000,1.0000000000000000000000000000000000000000000000000000000000000000)
$ g++ -O2 foo.cpp -o foo $ ./foo third1 = 0.333333333333333314829616256247390992939472198486328125000000 0000 third2 = 0.333333333333333314829616256247390992939472198486328125000000 0000 v1 = (1.000000000000000000000000000000000000000000000000000000000000 0000,1.0000000000000000000000000000000000000000000000000000000000000000) v2 = (1.000000000000000000000000000000000000000000000000000000000000 0000,1.0000000000000000000000000000000000000000000000000000000000000000)
I would expect to get the same output in both cases, but the lower end-points are different in the second case, and seem wrong to me since third2 * 3.0 < 1.0.
# On my Linux machine the effect is different: gcc version 5.4.0 20160609 boost 1.58 on Ubuntu 16.04.9
$ g++ foo.cpp -o foo $ ./foo third1 = 0.333333333333333314829616256247390992939472198486328125000000 0000 third2 = 0.333333333333333314829616256247390992939472198486328125000000 0000 v1 = (0.999999999999999888977697537484345957636833190917968750000000 0000,1.0000000000000000000000000000000000000000000000000000000000000000) v2 = (0.999999999999999888977697537484345957636833190917968750000000 0000,1.0000000000000000000000000000000000000000000000000000000000000000)
$ g++ -O2 foo.cpp -o foo $ ./foo third1 = 0.333333333333333314829616256247390992939472198486328125000000 0000 third2 = 0.333333333333333314829616256247390992939472198486328125000000 0000 v1 = (0.999999999999999888977697537484345957636833190917968750000000 0000,1.0000000000000000000000000000000000000000000000000000000000000000) v2 = (1.000000000000000000000000000000000000000000000000000000000000 0000,1.0000000000000000000000000000000000000000000000000000000000000000)
Can anyone explain what is going on?
Thanks in advance,
Tim
-- Tim van Erven
www.timvanerven.nl _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users