log1p_basic.phpt 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. --TEST--
  2. Test log1p() - basic function test log1p()
  3. --INI--
  4. precision=14
  5. --FILE--
  6. <?php
  7. /* Prototype : float log1p ( float $arg )
  8. * Description: Returns log(1 + number), 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 log1p() : basic functionality ***\n";
  13. $values = array(23,
  14. -23,
  15. 2.345e1,
  16. -2.345e1,
  17. 0x17,
  18. 027,
  19. "23",
  20. "23.45",
  21. "2.345e1",
  22. null,
  23. true,
  24. false);
  25. echo "\n LOG1p tests\n";
  26. foreach($values as $value) {
  27. echo "\n-- log1p $value --\n";
  28. var_dump(log1p($value));
  29. };
  30. ?>
  31. ===Done===
  32. --EXPECTF--
  33. *** Testing log1p() : basic functionality ***
  34. LOG1p tests
  35. -- log1p 23 --
  36. float(3.1780538303479)
  37. -- log1p -23 --
  38. float(NAN)
  39. -- log1p 23.45 --
  40. float(3.1966302159209)
  41. -- log1p -23.45 --
  42. float(NAN)
  43. -- log1p 23 --
  44. float(3.1780538303479)
  45. -- log1p 23 --
  46. float(3.1780538303479)
  47. -- log1p 23 --
  48. float(3.1780538303479)
  49. -- log1p 23.45 --
  50. float(3.1966302159209)
  51. -- log1p 2.345e1 --
  52. float(3.1966302159209)
  53. -- log1p --
  54. float(0)
  55. -- log1p 1 --
  56. float(0.69314718055995)
  57. -- log1p --
  58. float(0)
  59. ===Done===