-
Notifications
You must be signed in to change notification settings - Fork 63
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
SetString("3,60") returns a NaN instead of an error #153
Comments
Interesting! I assume NaN is incorrect, but I’ll need to double check the GDA spec first. |
The GDA spec says:
http://speleotrove.com/decimal/daconvs.html#reftonum Admittedly that’s unfortunate. Returning false sounds like it should be the correct behavior, even if it returns (NaN, false). I’ll see what I can do. |
Hi @ericlagergren, Is there any news regarding this? Thanks, |
The NaN check is to see if the result is NaN, which is a valid GDA decimal. But like I mentioned before, the library should be updated so that SetString("invalid") // NaN, false Ultimately, though, you'd still have to check if the result is NaN. A user could pass "NaN" instead of "3,60". |
You'll want to check the conditions: #166 (comment) |
@bojanz just adding myself here , after our chat on Reddit . @ericlagergren |
I've converted bojanz/currency from cockroachdb/apd to this package, and the tests are green:
bojanz/currency@2a46a5c
However, I was surprised by one difference in behavior between the two packages:
If I pass "3,60" to SetString(), which is a string with an invalid decimal separator, instead of getting nil, false I get NaN, true.
This forces me to check for NaN every time:
Is this intentional, or a bug?
The text was updated successfully, but these errors were encountered: