-
Notifications
You must be signed in to change notification settings - Fork 88
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
The float64 issue... again #144
Comments
Actually, it appears that it already did the same thing as 1 here. Why wasn't that acceptable? |
Information can be lost beforehand that the trunc check won't catch. Even a whole number integer could actually change into a different whole number integer (e.g. It would be convenient to still accept The doc says: // Note: The encoding/json package uses float64 for numbers by default, which is inaccurate
// for many web3 types, and unsupported here. The json.Decoder method UseNumber() will
// switch to using json.Number instead, which is accurate (full precision, backed by the
// original string) and supported here. And the current error is: How about adding this? -floating point numbers are not valid in web3 - please use an integer or string instead (including big.Int and json.Number)
+floating point numbers are not valid in web3 - please use an integer or string instead (including big.Int and json.Number) - see json.Decoder.UseNumber() |
I think we could resolve all these issues using shopspring/decimal. |
floats are just outright rejected as of this commit: a94ed0a
Which makes it annoying for JSON users.
Two ideas to make this a bit smoother.
if f == math.Trunc(f)
if you are parsing JSON, use decoder.UseNumber()
The text was updated successfully, but these errors were encountered: