func isFloatInt(floatValue float64) bool{
//What's the implementation here?
}
Test cases:
input: 1.5 output: false;
input: 1 output: true;
input:1.0 output: true;
I just checked on the playground, this does the right thing with NaN as well.
func isIntegral(val float64) bool {
return val == float64(int(val))
}
You could achieve it by doing a modulus
func isFloatInt(floatValue float64) bool {
return math.Mod(floatValue, 1.0) == 0
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With