PageRenderTime 40ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/2.0/Tests/@PHP/standard/math/abs.php

#
PHP | 21 lines | 18 code | 3 blank | 0 comment | 0 complexity | 8a523fa42d55c7736d3110bc00af837e MD5 | raw file
Possible License(s): CPL-1.0, GPL-2.0, CC-BY-SA-3.0, MPL-2.0-no-copyleft-exception, Apache-2.0
  1. [expect php]
  2. [file]
  3. <?
  4. define('LONG_MAX', is_int(5000000000)? 9223372036854775807 : 0x7FFFFFFF);
  5. define('LONG_MIN', -LONG_MAX - 1);
  6. printf("%d,%d,%d,%d\n",is_int(LONG_MIN ),is_int(LONG_MAX ),
  7. is_int(LONG_MIN-1),is_int(LONG_MAX+1));
  8. $tests = <<<TESTS
  9. 1 === abs(-1)
  10. 1.5 === abs(-1.5)
  11. 1 === abs("-1")
  12. 1.5 === abs("-1.5")
  13. -LONG_MIN+1 === abs(LONG_MIN-1)
  14. -LONG_MIN === abs(LONG_MIN)
  15. -(LONG_MIN+1) === abs(LONG_MIN+1)
  16. TESTS;
  17. include('quicktester.inc');
  18. ?>