Problem with rounding floating points
The problem is to take a floating point number (x) and look at it as if it's a time input in format HH.MM. If I enter, say 12.59 as x, the first cout outputs .59. The second one outputs 58. .59 * 100 is not 58. I can only assume some internal rounding is messing up my conversion.
int convMinutes(double x)
int mins = static_cast<int>(x) * 60;
cout << x - static_cast<int>(x);
mins = (x - static_cast<int>(x)) * 100;
cout << mins;
Any insights, ideas, would be much appreciated.