Be careful with double to int conversions. ints have a smaller max size then doubles so if the value is too high you will get some bad behaviour. In general casting like this is bad (although int to double is fine).
Pay attention to what Benny says.
You cannot convert a double to an int. Int has no decimal places. If you cast, you force a truncation of the decimal portion.
You can avoid the cast by a) calling a function that you write that has a double argument and returns an int, pr b) use a stringstream.
-
double d = 88.62;
-
stringstream ss;
-
ss << d;
-
int result;
-
ss >> result; //the 88
-
Here the decimal point and the decimal placesare still in the stringstream. You culd have this logic inside a function such that after you get the 88 youcould skip over the decimal point and retrieve the decimal places as a second int sop you could determine whether the result should be 88.62 or 88.63.
As a rule, do no mix integers and floating point. Floating point is generally for scientific use where extreme accuracy is not required.