Skip to content

spec: constant value truncated to integer #9779

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

Closed
mattn opened this issue Feb 5, 2015 · 1 comment
Closed

spec: constant value truncated to integer #9779

mattn opened this issue Feb 5, 2015 · 1 comment

Comments

@mattn
Copy link
Member

mattn commented Feb 5, 2015

Related issue #4565

println(int64(float64(7)/float64(3)+0.5))

This code become compile error. Using const is also.
http://play.golang.org/p/essxyc9aKX

package main

const (
    a = 7
    b = 3
)

func main() {
    println(int64(float64(a)/float64(b)+0.5))
}

But if the values are variables, it isn't.
http://play.golang.org/p/lHSeHRiG2G

a := 7.0
b := 3.0
println(int64(float64(a)/float64(b)+0.5))

I'm thinking, to express the expression, it's not useful to be error.

// r should be result of divides,
// (radius of the Earth) / (length of one step)
r := int(float64(RADIUS_OF_EARTH) / float64(LENGTH_OF_ONE_STEP))
@minux
Copy link
Member

minux commented Feb 5, 2015

This is basically #6923.

@minux minux closed this as completed Feb 5, 2015
@minux minux changed the title constant value truncated to integer spec: constant value truncated to integer Feb 5, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
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

3 participants