encode: use 64-bit parsing for float32s - #857
Merged
Merged
Conversation
Contributor
Author
|
@mjibson could you PTAL? |
|
LGTM |
madelynnblue
reviewed
May 3, 2019
Previously, float4 values were incorrectly parsed by this library. For example, a value of `1.2::float4` would be returned to the user as a float64 of `1.2000000476837158`. Now, float4s are parsed correctly, using the 64-bit-float string parsing facility, and return 1.2 as expected. Note that this problem only showed up if you used the returned float64 value from lib/pq directly - casting to a float32 would make the problem stay hidden - but since lib/pq returns float64, we should make an effort for that value to be correct anyway.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, float4 values were incorrectly parsed by this library. For
example, a value of
1.2::float4would be returned to the user as afloat64 of
1.2000000476837158. Now, float4s are parsed correctly,using the 64-bit-float string parsing facility, and return 1.2 as
expected. Note that this problem only showed up if you used the returned
float64 value from lib/pq directly - casting to a float32 would make the
problem stay hidden - but since lib/pq returns float64, we should make
an effort for that value to be correct anyway.
This was found during investigation here: cockroachdb/cockroach#36811