is there a way to convert a float to an Int by rounding to nearest whole integer?
cheers
Sam
is there a way to convert a float to an Int by rounding to nearest whole integer?
cheers
Sam
Actually Paul Beckingham's answer isn't quite correct. If you try a negative number like -1.51, you get -1 instead of -2.
The functions round(), roundf(), lround(), and lroundf() from math.h work for negative numbers too.