Skip to content

cmd/gc: inaccurate ideal float comparison #2789

@gopherbot

Description

@gopherbot

by fan.howard:

package main
import "fmt"
func main(){
    fmt.Println(0.1+0.2)
    fmt.Println(0.1+0.2 >= 0.3)
    fmt.Println(0.1+0.2 < 0.3)
    i := 0.1
    fmt.Println(i+0.2)
    fmt.Println(i+0.2 >= 0.3)
    fmt.Println(i+0.2 < 0.3)

}

result:

0.3
false
true
0.30000000000000004
true
false

go version weekly.2012-01-15 11253

same on http://play.golang.org/

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions