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

cmd/compile: float constant simplification drops sign #16824

Closed
crawshaw opened this issue Aug 21, 2016 · 1 comment
Closed

cmd/compile: float constant simplification drops sign #16824

crawshaw opened this issue Aug 21, 2016 · 1 comment

Comments

@crawshaw
Copy link
Member

https://play.golang.org/p/RawEfUJOP2

package main

import (
    "fmt"
)

func main() {
    var (
        vx float64 = 0
        vy float64 = -1
        vz float64 = vx*vy
    )
    fmt.Println("var:  ", vz)

    const (
        cx float64 = 0
        cy float64 = -1
        cz float64 = cx*cy
    )
    fmt.Println("const: ", cz)
}

Prints:

var:   -0
const:  0
@crawshaw
Copy link
Member Author

Oh, not a bug. The spec says: "Numeric constants represent exact values of arbitrary precision and do not overflow. Consequently, there are no constants denoting the IEEE-754 negative zero, infinity, and not-a-number values."

@golang golang locked and limited conversation to collaborators Aug 21, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants