#include #include double ToHalfAdjust(double dValue, int iDigits) { double dCoef; dCoef = pow(10, iDigits); return dValue > 0 ? floor(dValue * dCoef + 0.5) / dCoef: ceil(dValue * dCoef - 0.5) / dCoef; } void MathToHalfAdjust(void) { double dst; dst = ToHalfAdjust(12.325, 2); printf("%f\n", dst); /* 12.33 */ } int main(void) { MathToHalfAdjust(); return 0; }