Nico Buescher
03/26/2020, 6:29 PM#include <stdio.h>
float fract(float x) {
return x - (long)x;
}
int main() {
printf("%f", fract(2.3f));
}
with output 0.3
, I expected the same output from kotlin code:
fun fract(x: Float): Float {
return x - x.toLong()
}
fun main() {
println(fract(2.3f))
}
instead I get: 0.29999995
What's happening here?Erik Christensen
03/26/2020, 6:40 PMMarkus Böck
03/26/2020, 6:42 PMMarkus Böck
03/26/2020, 6:42 PMNico Buescher
03/26/2020, 6:43 PM