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

ZArith's built-in test suite reports errors on 64bit Windows (both native and on Cygwin) #25

Closed
martin-neuhaeusser opened this issue Jan 2, 2018 · 2 comments

Comments

@martin-neuhaeusser
Copy link
Contributor

While working on #23, it occurred to me that ZArith's own test suite consistently reports errors on Windows 64 bit builds. I attached the outputs of the zq. exe test binary here:
zarith_test_failures.tar.gz

All tests have been conducted with OCaml 4.06.0 and the latest ZArith on github.

It seems that some floating-point precision is lost on both Windows ports.
Even more disturbing, the results also differ between the Cygwin and the native built.
Platform-specific assembly code does not seem to influence the outcomes.

@xavierleroy
Copy link
Contributor

Thank you for reporting this issue. I think the computed results are correct, it's just the test itself that is poorly designed. Namely, it prints large FP numbers with %f format, which forces many digits to be printed, well beyond the precision of the FP number. For example:

- = 2037035976334486086268445688409378161051468393665936250636140449354381299763336706183397376.000000
+ = 2037035976334486086268445688409378161051468000000000000000000000000000000000000000000000000.000000

The two printed values look different, but are actually equal when converted back to a double-precision FP number.

OCaml delegates the printing of FP numbers to the C standard library, so different C libraries (e.g. Linux vs Cygwin vs Microsoft) can print the same FP number differently.

I'll look into making the test more robust.

@xavierleroy
Copy link
Contributor

Commit 37aeb86 should fix this issue.

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

2 participants