This is a simple question:
Is this a correct way to get an integer part from a float division?
int result = myFloat / anInteger;
this is working, but I am not sure if it is the best way.
thanks for any help.
This is a simple question:
Is this a correct way to get an integer part from a float division?
int result = myFloat / anInteger;
this is working, but I am not sure if it is the best way.
thanks for any help.
To truncate:
int result = (int)(myFloat / anInteger);
Other conversion options:
#include <math.h>
int result = (int)ceilf(myFloat / anInteger);
int result = (int)roundf(myFloat / anInteger);
int result = (int)floorf(myFloat / anInteger);