double a = 3.185, b = 3.195; a = (int)((a * 1000 + 5) / 10) / 100.0; b = (int)((b * 1000 + 5) / 10) / 100.0; printf("a = %.3f\nb = %.3f", a, b);