expm1_basic.phpt 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. --TEST--
  2. Test expm1() - basic function test for expm1()
  3. --INI--
  4. precision=14
  5. --FILE--
  6. <?php
  7. /* Prototype : float expm1 ( float $arg )
  8. * Description: Returns exp(number) - 1, computed in a way that is accurate even
  9. * when the value of number is close to zero.
  10. * Source code: ext/standard/math.c
  11. */
  12. echo "*** Testing expm1() : basic functionality ***\n";
  13. $values = array(10,
  14. 10.3,
  15. 3.9505e3,
  16. 037,
  17. 0x5F,
  18. "10",
  19. "3950.5",
  20. "3.9505e3",
  21. "039",
  22. "0x5F",
  23. true,
  24. false,
  25. null,
  26. );
  27. // loop through each element of $values to check the behaviour of expm1()
  28. $iterator = 1;
  29. foreach($values as $value) {
  30. echo "\n-- Iteration $iterator --\n";
  31. var_dump(expm1($value));
  32. $iterator++;
  33. };
  34. ?>
  35. ===Done===
  36. --EXPECTF--
  37. *** Testing expm1() : basic functionality ***
  38. -- Iteration 1 --
  39. float(22025.465794807)
  40. -- Iteration 2 --
  41. float(29731.618852891)
  42. -- Iteration 3 --
  43. float(INF)
  44. -- Iteration 4 --
  45. float(29048849665246)
  46. -- Iteration 5 --
  47. float(1.811239082889E+41)
  48. -- Iteration 6 --
  49. float(22025.465794807)
  50. -- Iteration 7 --
  51. float(INF)
  52. -- Iteration 8 --
  53. float(INF)
  54. -- Iteration 9 --
  55. float(8.6593400423994E+16)
  56. -- Iteration 10 --
  57. float(1.811239082889E+41)
  58. -- Iteration 11 --
  59. float(1.718281828459)
  60. -- Iteration 12 --
  61. float(0)
  62. -- Iteration 13 --
  63. float(0)
  64. ===Done===