-
Notifications
You must be signed in to change notification settings - Fork 185
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
Strange conversion to PgNumeric #241
Comments
Seems like there is a need of normalisation before serialising decimal to Postgres value. |
This does look like incorrect behavior. I believe the issue is due to the weight being While normalization works around this issue, it still means that 1 significant figure of precision is lost. I'll take a look at this later today and see what I can find. |
Took a look again. Normalization doesn't work correctly also. For example |
From investigation, this looks specific to the write logic as opposed to the read logic. This is definitely isolated to the It seems like this is to do with the algorithm doing an "exhaustive" loop until the mantissa is zero. Because it exits "early" it effectively truncates instead of adding in the trailing zero's. I want to ensure any solution does some exhaustive testing around this scenario (e.g. including multiple trailing zero groups) so will work on the solution over the next couple of days to ensure I cover all edge cases. |
I have made my implementation of serialise, deserialize based on PG docs and bigdecimal impls. Added some tests of trailing zeroes. If you want I can do a pr? |
Added PR #243 |
Recently I came across strange behavior.
This code:
prints:
Trailing zero causes this problem. Value
0.00000166
is serialized how it should beThe text was updated successfully, but these errors were encountered: