xref: /PHP-8.2/ext/standard/tests/math/abs.phpt (revision 3a4b8966)
1--TEST--
2Simple math tests
3--FILE--
4<?php
5
6define('LONG_MAX', is_int(5000000000)? 9223372036854775807 : 0x7FFFFFFF);
7define('LONG_MIN', -LONG_MAX - 1);
8printf("%d,%d,%d,%d\n",is_int(LONG_MIN  ),is_int(LONG_MAX  ),
9                       is_int(LONG_MIN-1),is_int(LONG_MAX+1));
10
11var_dump(1   === abs(-1));
12var_dump(1.5 === abs(-1.5));
13var_dump(1   === abs("-1"));
14var_dump(1.5 === abs("-1.5"));
15var_dump(-LONG_MIN+1 === abs(LONG_MIN-1));
16var_dump(-LONG_MIN   === abs(LONG_MIN));
17var_dump(-(LONG_MIN+1) === abs(LONG_MIN+1));
18
19?>
20--EXPECT--
211,1,0,0
22bool(true)
23bool(true)
24bool(true)
25bool(true)
26bool(true)
27bool(true)
28bool(true)
29