I am having some trouble rounding some special float numbers to integers.
I need to round a float number to an integer (if and only if) the first three float point values are zeros or 9’s.
For example if the number was 4.0001 I need to round this to 4. and if the number was 4.9998 I need to round it to 5. Other than that, the values should be displayed as they are.
In other words I need to print an integer only if the above two rules were met, otherwise I should print float numbers,
How can one achieve this in C++.
Regards
If you’re interested in the fractional part,
modfis your friend. Saysomething like: