fork download
  1. #include <stdio.h>
  2. #define ROUND3(number) ( (int)( (number) * 1000 + 0.5 ) / 1000.0 )
  3. int main()
  4. {
  5. double A = 0.0306880000, B = 0.0396640000;
  6. printf ("A = %5.3f; B = %5.3f\n", A, B);
  7. double AB = ROUND3(A) + ROUND3(B);
  8. printf ("ROUND3(A) = %f, ROUND3(B) = %f\n", ROUND3(A), ROUND3(B));
  9. printf ("AB = %f\n", AB);
  10.  
  11. return 0;
  12. }
Success #stdin #stdout 0s 9432KB
stdin
Standard input is empty
stdout
A = 0.031; B = 0.040
ROUND3(A) = 0.031000, ROUND3(B) = 0.040000
AB = 0.071000