Skip to content
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

Fix signed zero handling in expr.LookupCompare #4861

Merged
merged 3 commits into from
Nov 9, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions runtime/expr/sort.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,10 @@ func LookupCompare(typ zed.Type) comparefn {
return func(a, b zcode.Bytes) int {
va, vb := zed.DecodeFloat(a), zed.DecodeFloat(b)
aNaN, bNaN := math.IsNaN(va), math.IsNaN(vb)
if aNaN && bNaN {
// Order different NaNs so ZNG sets have a canonical form.
aBits, bBits := math.Float64bits(va), math.Float64bits(vb)
if va == 0.0 && vb == 0.0 || aNaN && bNaN {
// Order different zeroes and NaNs so ZNG sets
// have a canonical form.
aBits, bBits := int64(math.Float64bits(va)), int64(math.Float64bits(vb))
if aBits < bBits {
return -1
} else if aBits > bBits {
Expand Down