Best way to round float

Hey! easy question.
Whats the best way to round a float to 3 decimals.
3.193029 to 3.193

Answer

float val =1.333333;

float nearest = roundf(val * 100) / 100;

cout << nearest << endl;
4 Likes