t438.py 884 B

123456789101112131415161718192021222324252627282930313233343536
  1. import math
  2. print "\nmath.ceil(x)"
  3. print math.ceil(0.0) == 0
  4. print math.ceil(-0.1) == 0
  5. print math.ceil(-0.4) == 0
  6. print math.ceil(-0.5) == 0
  7. print math.ceil(-0.9) == 0
  8. print math.ceil(0.1) == 1
  9. print math.ceil(0.4) == 1
  10. print math.ceil(0.5) == 1
  11. print math.ceil(0.9) == 1
  12. print "\nmath.fabs(x)"
  13. print math.fabs(-1) == 1.0
  14. print math.fabs(1) == 1.0
  15. print math.fabs(0) == 0.0
  16. print "\nmath.floor(x)"
  17. print math.floor(0.0) == 0
  18. print math.floor(-0.1) == -1
  19. print math.floor(-0.4) == -1
  20. print math.floor(-0.5) == -1
  21. print math.floor(-0.9) == -1
  22. print math.floor(0.1) == 0
  23. print math.floor(0.4) == 0
  24. print math.floor(0.5) == 0
  25. print math.floor(0.9) == 0
  26. print "\nmath.trunc(x)"
  27. print math.trunc(12.34) == 12
  28. print math.trunc(-12.34) == -12
  29. print math.trunc(5.67e+8) == 567000000
  30. print math.trunc(-5.67e+8) == -567000000
  31. print math.trunc(5.67e-8) == 0
  32. print math.trunc(-5.67e-8) == 0