0
How to turn any floating point value to integer??
10.1 turns to 11 , 10.9 also to 11
2 Réponses
+ 2
You can try to break a floating point value into its integer and fractional part by using `modf` function. Will need to include <cmath> for this.
http://www.cplusplus.com/reference/cmath/modf/
P.S. I wouldn't expect much about accuracy, casting floating point data into integer had long known for being rather problematic : )
+ 1
or by using ceil()
#include<math.h >
float f =10.1;
int i = ceil(f);
cout << i;