Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slight rounding difference in core tests #168

Closed
dbr opened this issue Oct 4, 2011 · 5 comments
Closed

Slight rounding difference in core tests #168

dbr opened this issue Oct 4, 2011 · 5 comments

Comments

@dbr
Copy link
Contributor

dbr commented Oct 4, 2011

The change on b7dd8d8 breaks the tests for me on OS X 10.6/10.7:

.../src/core/FileFormatHDL.cpp:1449:
FAILED: OCIO::pystring::strip(osvec[i]) == OCIO::pystring::strip(resvec[i])
    values were '0.732058' and '0.732057'

No idea why it would cause the slight difference.. Only vaguely useful thing I can think to say is I'm using i686-apple-darwin11-llvm-g++-4.2, and the executable was built with the following command (excluding a bunch of .o files):

/usr/bin/c++   -Wall -Wextra -Wshadow -Wconversion -Wcast-qual -Wformat=2 -msse2 -O2 -g -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.7.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names  [....]  -o ocio_core_tests  ../../ext/dist/lib/libtinyxml.a ../../ext/dist/lib/libyaml-cpp.a
@jeremyselan
Copy link
Contributor

Thanks for the heads up. Yah, I see that on OSX too. Not sure what the cause it. Probably wont have time to look into it in the short-term, but if you care to investigate it further please fill me in on what you find.

@dbr
Copy link
Contributor Author

dbr commented Jan 10, 2012

Interesting, the value that differs is 4.0/9.0 ** (1/2.6), and:

$ uname -s
Darwin
$ gcc -v
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2335.15~25/src/configure --disable-checking --enable-werror --prefix=/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2335.15~25/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)

$ cat roundtest.c 
#include<iostream>
#include<math.h>
int main(){
    std::cout << powf(4.0/9.0, (1.0/2.6)) << "\n";
}
$ g++ roundtest.c && ./a.out
0.732058
$ python2.7 -c 'print "%.06f" % (4.0/9.0)**(1/2.6)'
0.732057

Where the expected value on Linux is 0.732057

Wolfram|Alpha agrees with Linux, http://www.wolframalpha.com/input/?i=%284.0%2F9.0%29**%281%2F2.6%29

@dbr
Copy link
Contributor Author

dbr commented Jan 10, 2012

Oh, it's a gcc version thing:

$ uname -s
Linux
$ run in gcc/4.1.2 : g++ roundtest.c && ./a.out
0.732057
$ run in gcc/4.4.0 : g++ roundtest.c && ./a.out
0.732058

@dbr
Copy link
Contributor Author

dbr commented Jan 10, 2012

@jeremyselan
Copy link
Contributor

Interesting result (that it changes between gcc versions), and +1 for the nice stackoverflow answers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants