sqrt_variation.phpt 813 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. --TEST--
  2. Test variations in usage of sqrt()
  3. --INI--
  4. precision = 14
  5. --FILE--
  6. <?php
  7. /*
  8. * Function is implemented in ext/standard/math.c
  9. */
  10. //Test sqrt with a different input values
  11. echo "*** Testing sqrt() : usage variations ***\n";
  12. $values = array(23,
  13. -23,
  14. 2.345e1,
  15. -2.345e1,
  16. 0x17,
  17. 027,
  18. "23",
  19. "23.45",
  20. "2.345e1",
  21. "1000",
  22. true,
  23. false);
  24. for ($i = 0; $i < count($values); $i++) {
  25. $res = sqrt($values[$i]);
  26. var_dump($res);
  27. }
  28. ?>
  29. --EXPECT--
  30. *** Testing sqrt() : usage variations ***
  31. float(4.795831523312719)
  32. float(NAN)
  33. float(4.8425200051213)
  34. float(NAN)
  35. float(4.795831523312719)
  36. float(4.795831523312719)
  37. float(4.795831523312719)
  38. float(4.8425200051213)
  39. float(4.8425200051213)
  40. float(31.622776601683793)
  41. float(1)
  42. float(0)