func isFloatInt(floatValue float64) bool{
//What's the implementation here?
}
測試用例:
輸入:1.5輸出:假的;
輸入:1輸出:真;
輸入:1.0輸出:真;
轉到郎如何檢查浮點值實際上是詮釋
func isFloatInt(floatValue float64) bool{
//What's the implementation here?
}
測試用例:
輸入:1.5輸出:假的;
輸入:1輸出:真;
輸入:1.0輸出:真;
轉到郎如何檢查浮點值實際上是詮釋
我只是checked on the playground,這確實與南正確的事,以及實現這一目標。
func isIntegral(val float64) bool {
return val == float64(int(val))
}
作爲郎朗的新手,感謝您的幫助! – dongyan
你可以做一個模
func isFloatInt(floatValue float64) bool {
return math.Mod(floatValue, 1.0) == 0
}
有什麼想法? .. – zerkms
測試它是否等於它自己的['Floor'](https://golang.org/pkg/math/#Floor)? –
https://golang.org/pkg/math/#Trunc – Volker