#include <iostream>
#include <cmath>
/**
* Rounds a double to a specified number of decimal places.
*
* return the rounded number
*/
double roundTo(double n, int roundto) {
roundto = pow(10, roundto);
return std::round(n * roundto) / roundto;
}
int main()
{
double n = 89.560873;
// Round to 3 decimal places
n = roundTo(n, 3);
std::cout << n << std::endl;
}
/*
run:
89.561
*/