It seems that the easiest way to change from floats to ints is by casting, but this may lead to errors. In Pascal I use round, but C lacks of a similar function. I'm currently using this function but I want to know if there's a better way.
Code: Select all
long float_to_int(double fX) {
return((fX -((long) fX) < 0.5) ? ((long) fX) : ((long) fX+1) );
}