-
Notifications
You must be signed in to change notification settings - Fork 72
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
Floating point values. #1
Comments
Tip: For Python parsers, I used |
(Not sure what you mean about Python, if this is to interact with this suite, the |
@Julian It's much more subtle than that. This transcript might make things clearer: >>> f = 3.141592653589793
>>> print str(f)
3.14159265359
>>> print repr(f)
3.141592653589793 |
Ah, I might see the source of your confusion now. JSON serialization doesn't really apply here, since the interface of the tester reads all primitive values as strings. So you can't just take a dictionary representation of the interface and dump it as JSON. You've got to make sure all your values are strings. |
My comment was before you pointed out that your interface is expecting strings. If that's true, then the |
What value of epsilon do you suggest I use? |
It's not clear to me that this is a problem in practice. Moreover, an approximate equality check typically requires some notion of what one believes is accurate. I don't know what that means in this context. If someone comes across this problem in the real world, please leave a comment and I'll re-open the issue. |
Not an epsilon-related issue, but an issue related to comparing float values. When comparing "nan" floats, parsing to a float64 and comparing the expected and actual version using if expectedFloat != actualFloat && !(math.IsNaN(expectedFloat) && math.IsNaN(actualFloat)) {
// error handling here...
} |
I believe the treatment of 64 bit integers in the test suite is solid, but I think testing floating point values has holes.
It is partially mitigated by the fact that all values are encoded as JSON strings. This means that we can interpret all floating point values as Go does and perform a proper equality test.
However, different languages may have different floating point representations. Which means that some languages might produce different values---which poses problems for an equality test.
In practice, this may not be so much of an issue since floating point conversion is typically well-handled by the language being used. However, it may be worth it to come up with tests for sufficiently small and large numbers that are not reliably represented in practice.
Overall, I'm not sure. And I have only a passing familiarity with the inner workings of floating point representation to know if this is a real issue or not.
The text was updated successfully, but these errors were encountered: