Simple question, of the record (NOT an opengl question…). I need to know how I round a float, if it’s 15.00000001 and I want it to be rounded to 15, how do I do???
Thanx…
Simple question, of the record (NOT an opengl question…). I need to know how I round a float, if it’s 15.00000001 and I want it to be rounded to 15, how do I do???
Thanx…
Use the floor(MyFloat).
If you want to round towards closest int you can use floor(MyFloat + 0.5);
If you’re dealing with strictly non-negative numbers, then you can just let C truncate it for you if you do auto-type conversion to an int, for example:
float x = 15.0000001;
int rounded;
rounded = (int) x; // yields 15
rounded = x; // this works as well
ec