xref: /PHP-7.0/ext/standard/tests/math/abs_basic.phpt (revision a7bdc765)
1--TEST--
2Test abs() function : basic functionality
3--INI--
4precision = 14
5--FILE--
6<?php
7/* Prototype  : number abs  ( mixed $number  )
8 * Description: Returns the absolute value of number.
9 * Source code: ext/standard/math.c
10 */
11
12echo "*** Testing abs() : basic functionality ***\n";
13
14$values = array(23,
15				-23,
16				2.345e1,
17				-2.345e1,
18				0x17,
19				027,
20				"23",
21				"-23",
22				"23.45",
23				"2.345e1",
24				"-2.345e1",
25				null,
26				true,
27				false);
28
29for ($i = 0; $i < count($values); $i++) {
30	$res = abs($values[$i]);
31	var_dump($res);
32}
33?>
34===Done===
35--EXPECTF--
36*** Testing abs() : basic functionality ***
37int(23)
38int(23)
39float(23.45)
40float(23.45)
41int(23)
42int(23)
43int(23)
44int(23)
45float(23.45)
46float(23.45)
47float(23.45)
48int(0)
49int(1)
50int(0)
51===Done===