golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
124.14k stars 17.69k forks source link

x/text/collate: CompareString(collate.Numeric) returns wrong result for "0.0" vs "1.0" #67997

Open wxiaoguang opened 5 months ago

wxiaoguang commented 5 months ago

Go version

go version go1.22.1 darwin/arm64

Output of go env in your module/workspace:

N/A

What did you do?

    c := collate.New(language.English, collate.Numeric)
    r1 := c.CompareString("0", "1")
    r2 := c.CompareString("0.0", "1.0")
    println(r1, r2)

What did you see happen?

r1 == -1 and r2 == 1 (WRONG)

What did you expect to see?

r1 == -1 and r2 == -1

lordwelch commented 1 week ago

My PR golang/text#50 should fix this as well