fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3. int main(void) {
  4. double x = 9.0/5;
  5. double y = 6.0/5;
  6. double z = -6.0/5;
  7.  
  8. printf("ceil(%.2lf)=%.0lf, ceil(%.2lf)=%.0lf, ceil(%.2lf)=%.0lf\n",
  9. x,ceil(x),y,ceil(y),z,ceil(z));
  10. printf("floor(%.2lf)=%.0lf, floor(%.2lf)=%.0lf, floor(%.2lf)=%.0lf\n",
  11. x,floor(x),y,floor(y),z,floor(z));
  12. printf("round(%.2lf)=%.0lf, round(%.2lf)=%.0lf, round(%.2lf)=%.0lf\n",
  13. x,round(x),y,round(y),z,round(z));
  14. printf("trunc(%.2lf)=%.0lf, trunc(%.2lf)=%.0lf, trunc(%.2lf)=%.0lf\n",
  15. x,trunc(x),y,trunc(y),z,trunc(z));
  16.  
  17. return 0;
  18. }
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
ceil(1.80)=2, ceil(1.20)=2, ceil(-1.20)=-1
floor(1.80)=1, floor(1.20)=1, floor(-1.20)=-2
round(1.80)=2, round(1.20)=1, round(-1.20)=-1
trunc(1.80)=1, trunc(1.20)=1, trunc(-1.20)=-1