Reading the source code of math/floor.go
, starting from line 13, I read some code like this:
func Floor(x float64) float64
func floor(x float64) float64 {
if x == 0 || IsNaN(x) || IsInf(x, 0) {
return x
}
if x < 0 {
d, fract := Modf(-x)
if fract != 0.0 {
d = d + 1
}
return -d
}
d, _ := Modf(x)
return d
}
It seems the func Floor
has no body. I tried to copy and paste these code in my go file. it doesn't compile. The error message is missing function body
. So my question is: is a bodiless function legal in Go's syntax? Thanks.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…