fix(apiquery): format float32 query values at float32 precision - #87
Open
latent-9 wants to merge 1 commit into
Open
fix(apiquery): format float32 query values at float32 precision#87latent-9 wants to merge 1 commit into
latent-9 wants to merge 1 commit into
Conversation
The query encoder shared one case between Float32 and Float64 and formatted both with bitSize 64, so a float32 like 0.1 was serialized as 0.10000000149011612 instead of 0.1. The form encoder already splits the two cases; mirror that here, and cover float32 in the encoder table.
This was referenced Aug 26, 2026
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.
What
The query encoder shared a single case between
reflect.Float32andreflect.Float64and formatted both with bitSize 64.Why
strconv.FormatFloat(value.Float(), 'f', -1, 64)produces the shortest representation that round-trips as a float64. For a float32 like0.1that yields0.10000000149011612instead of0.1, so float32 query parameters went out with float64 noise digits. The form encoder in this repo already splits the two cases (internal/apiform/encoder.go) and formats Float32 at bitSize 32; the query encoder now mirrors that.Change
Split the case and format Float32 at bitSize 32, plus a
float32(0.1)row in the encoder table test.