floor_basic.phpt 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. --TEST--
  2. Test floor() - basic function test for floor()
  3. --INI--
  4. precision=14
  5. --FILE--
  6. <?php
  7. /* Prototype : float floor ( float $value )
  8. * Description: Round fractions down.
  9. * Source code: ext/standard/math.c
  10. */
  11. echo "*** Testing floor() : basic functionality ***\n";
  12. $values = array(0,
  13. -0,
  14. 0.5,
  15. -0.5,
  16. 1,
  17. -1,
  18. 1.5,
  19. -1.5,
  20. 2.6,
  21. -2.6,
  22. 037,
  23. 0x5F,
  24. "10.5",
  25. "-10.5",
  26. "3.95E3",
  27. "-3.95E3",
  28. "039",
  29. "0x5F",
  30. true,
  31. false,
  32. null,
  33. );
  34. foreach($values as $value) {
  35. echo "\n-- floor $value --\n";
  36. var_dump(floor($value));
  37. };
  38. ?>
  39. ===Done===
  40. --EXPECTF--
  41. *** Testing floor() : basic functionality ***
  42. -- floor 0 --
  43. float(0)
  44. -- floor 0 --
  45. float(0)
  46. -- floor 0.5 --
  47. float(0)
  48. -- floor -0.5 --
  49. float(-1)
  50. -- floor 1 --
  51. float(1)
  52. -- floor -1 --
  53. float(-1)
  54. -- floor 1.5 --
  55. float(1)
  56. -- floor -1.5 --
  57. float(-2)
  58. -- floor 2.6 --
  59. float(2)
  60. -- floor -2.6 --
  61. float(-3)
  62. -- floor 31 --
  63. float(31)
  64. -- floor 95 --
  65. float(95)
  66. -- floor 10.5 --
  67. float(10)
  68. -- floor -10.5 --
  69. float(-11)
  70. -- floor 3.95E3 --
  71. float(3950)
  72. -- floor -3.95E3 --
  73. float(-3950)
  74. -- floor 039 --
  75. float(39)
  76. -- floor 0x5F --
  77. float(95)
  78. -- floor 1 --
  79. float(1)
  80. -- floor --
  81. float(0)
  82. -- floor --
  83. float(0)
  84. ===Done===