tdewolff / parse

Go parsers for web formats
MIT License
413 stars 65 forks source link

TestParseDecimal/5.1 no longer passes #115

Closed QuLogic closed 11 months ago

QuLogic commented 1 year ago

This is probably dependent on architecture in some way, or floating-point optimizations. I am running on a now somewhat older x86_64 though, so it's not too esoteric.

--- FAIL: TestParseDecimal (0.00s)
    --- FAIL: TestParseDecimal/5.1 (0.00s)
    decimal_test.go:26: 5.1000000000000005 != 5.1

This occurs with the older github.com/tdewolff/test 1.0.9 that had absolute comparisons, or with the newer 1.0.10 that has relative comparisons.

tdewolff commented 1 year ago

Thanks for the report. Can't figure out what's wrong here, with Epsilon = 1e-10:

Absolute: 5.1000000000000005 - 5.1 = 5e-16 < 1e-10

Relative: (5.1000000000000005 - 5.1) / 5.1 ≈ 1e-16 < 1e-10

For both cases the test should pass (as it does on my computer), not sure what is wrong...

tdewolff commented 1 year ago

Pushed out a change in the test package, maybe that fixes it?

QuLogic commented 12 months ago

Thanks, it looks like 2.7.1 works, and I didn't need to use the intermediate commit of the test package.

Edit: And also 2.7.4 works, without the change to test as well.