Have another look at the precedence of operators and check if roundIt is really doing what you think.
If it helps define some variables to various parts of the equation and make sure they're correct, e.g. double p1=pow(10.0, n), then replace pow(10.0, n) with p1.