How do you round off decimal places in C++?
c++, floating-point, precision
Solution
There's another solution which doesn't require casting to int:
#include <cmath>
y = floor(x * 10d) / 10d
Problem
I need help rounding off a float value to one decimal place. I know `setprecision(x)` and `cout << precision(x)`. Both of which work if I wanted to round the entire float, but I am only interested in rounding the decimals to the tenths place.