Skip to content

Issue with NaN not comparable so piling up in Set[float64] #13

@ldemailly

Description

@ldemailly

https://go.dev/play/p/2L3NR09zIJu

package main

import (
	"fmt"
	"math"

	"fortio.org/sets"
)

func test(v float64) {
	set := sets.New(v, v, v, v)
	set.Add(v, v, v)
	fmt.Printf("Using %f : %d elems %v and has: %v\n", v, len(set), set, set.Has(v))
}

func main() {
	test(math.Pi)
	test(math.NaN())
}

outputs

# As expected
Using 3.141593 : 1 elems 3.141592653589793 and has: true
# Not great
Using NaN : 7 elems NaN,NaN,NaN,NaN,NaN,NaN,NaN and has: false

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions