diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2013-03-14 05:42:27 +0000 |
---|---|---|
committer | <> | 2013-04-03 16:25:08 +0000 |
commit | c4dd7a1a684490673e25aaf4fabec5df138854c4 (patch) | |
tree | 4d57c44caae4480efff02b90b9be86f44bf25409 /ext/standard/tests/math/round_basic.phpt | |
download | php2-master.tar.gz |
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/standard/tests/math/round_basic.phpt')
-rw-r--r-- | ext/standard/tests/math/round_basic.phpt | 192 |
1 files changed, 192 insertions, 0 deletions
diff --git a/ext/standard/tests/math/round_basic.phpt b/ext/standard/tests/math/round_basic.phpt new file mode 100644 index 0000000..dd4725f --- /dev/null +++ b/ext/standard/tests/math/round_basic.phpt @@ -0,0 +1,192 @@ +--TEST-- +Test round() - basic function test for round() +--INI-- +precision=14 +--FILE-- +<?php +/* Prototype : float round ( float $val [, int $precision ] ) + * Description: Returns the rounded value of val to specified precision (number of digits + * after the decimal point) + * Source code: ext/standard/math.c + */ + +echo "*** Testing round() : basic functionality ***\n"; + +$values = array(123456789, + 123.456789, + -4.5679123, + 1.23E4, + -4.567E3, + 0x234567, + 067777777, + "1.234567", + "2.3456789e8", + "0x1234CDEF"); + +$precision = array(2, + 8, + 0x3, + 04, + 3.6, + "2", + "0x03", + "04", + "3.6", + "2.1e1", + null, + true, + false); + +for ($i = 0; $i < count($values); $i++) { + echo "round: $values[$i]\n"; + for ($j = 0; $j < count($precision); $j++) { + $res = round($values[$i], $precision[$j]); + echo "...with precision $precision[$j]-> "; + var_dump($res); + } +} +?> +===Done=== +--EXPECTF-- +*** Testing round() : basic functionality *** +round: 123456789 +...with precision 2-> float(123456789) +...with precision 8-> float(123456789) +...with precision 3-> float(123456789) +...with precision 4-> float(123456789) +...with precision 3.6-> float(123456789) +...with precision 2-> float(123456789) +...with precision 0x03-> float(123456789) +...with precision 04-> float(123456789) +...with precision 3.6-> float(123456789) +...with precision 2.1e1-> float(123456789) +...with precision -> float(123456789) +...with precision 1-> float(123456789) +...with precision -> float(123456789) +round: 123.456789 +...with precision 2-> float(123.46) +...with precision 8-> float(123.456789) +...with precision 3-> float(123.457) +...with precision 4-> float(123.4568) +...with precision 3.6-> float(123.457) +...with precision 2-> float(123.46) +...with precision 0x03-> float(123.457) +...with precision 04-> float(123.4568) +...with precision 3.6-> float(123.457) +...with precision 2.1e1-> float(123.456789) +...with precision -> float(123) +...with precision 1-> float(123.5) +...with precision -> float(123) +round: -4.5679123 +...with precision 2-> float(-4.57) +...with precision 8-> float(-4.5679123) +...with precision 3-> float(-4.568) +...with precision 4-> float(-4.5679) +...with precision 3.6-> float(-4.568) +...with precision 2-> float(-4.57) +...with precision 0x03-> float(-4.568) +...with precision 04-> float(-4.5679) +...with precision 3.6-> float(-4.568) +...with precision 2.1e1-> float(-4.5679123) +...with precision -> float(-5) +...with precision 1-> float(-4.6) +...with precision -> float(-5) +round: 12300 +...with precision 2-> float(12300) +...with precision 8-> float(12300) +...with precision 3-> float(12300) +...with precision 4-> float(12300) +...with precision 3.6-> float(12300) +...with precision 2-> float(12300) +...with precision 0x03-> float(12300) +...with precision 04-> float(12300) +...with precision 3.6-> float(12300) +...with precision 2.1e1-> float(12300) +...with precision -> float(12300) +...with precision 1-> float(12300) +...with precision -> float(12300) +round: -4567 +...with precision 2-> float(-4567) +...with precision 8-> float(-4567) +...with precision 3-> float(-4567) +...with precision 4-> float(-4567) +...with precision 3.6-> float(-4567) +...with precision 2-> float(-4567) +...with precision 0x03-> float(-4567) +...with precision 04-> float(-4567) +...with precision 3.6-> float(-4567) +...with precision 2.1e1-> float(-4567) +...with precision -> float(-4567) +...with precision 1-> float(-4567) +...with precision -> float(-4567) +round: 2311527 +...with precision 2-> float(2311527) +...with precision 8-> float(2311527) +...with precision 3-> float(2311527) +...with precision 4-> float(2311527) +...with precision 3.6-> float(2311527) +...with precision 2-> float(2311527) +...with precision 0x03-> float(2311527) +...with precision 04-> float(2311527) +...with precision 3.6-> float(2311527) +...with precision 2.1e1-> float(2311527) +...with precision -> float(2311527) +...with precision 1-> float(2311527) +...with precision -> float(2311527) +round: 14680063 +...with precision 2-> float(14680063) +...with precision 8-> float(14680063) +...with precision 3-> float(14680063) +...with precision 4-> float(14680063) +...with precision 3.6-> float(14680063) +...with precision 2-> float(14680063) +...with precision 0x03-> float(14680063) +...with precision 04-> float(14680063) +...with precision 3.6-> float(14680063) +...with precision 2.1e1-> float(14680063) +...with precision -> float(14680063) +...with precision 1-> float(14680063) +...with precision -> float(14680063) +round: 1.234567 +...with precision 2-> float(1.23) +...with precision 8-> float(1.234567) +...with precision 3-> float(1.235) +...with precision 4-> float(1.2346) +...with precision 3.6-> float(1.235) +...with precision 2-> float(1.23) +...with precision 0x03-> float(1.235) +...with precision 04-> float(1.2346) +...with precision 3.6-> float(1.235) +...with precision 2.1e1-> float(1.234567) +...with precision -> float(1) +...with precision 1-> float(1.2) +...with precision -> float(1) +round: 2.3456789e8 +...with precision 2-> float(234567890) +...with precision 8-> float(234567890) +...with precision 3-> float(234567890) +...with precision 4-> float(234567890) +...with precision 3.6-> float(234567890) +...with precision 2-> float(234567890) +...with precision 0x03-> float(234567890) +...with precision 04-> float(234567890) +...with precision 3.6-> float(234567890) +...with precision 2.1e1-> float(234567890) +...with precision -> float(234567890) +...with precision 1-> float(234567890) +...with precision -> float(234567890) +round: 0x1234CDEF +...with precision 2-> float(305450479) +...with precision 8-> float(305450479) +...with precision 3-> float(305450479) +...with precision 4-> float(305450479) +...with precision 3.6-> float(305450479) +...with precision 2-> float(305450479) +...with precision 0x03-> float(305450479) +...with precision 04-> float(305450479) +...with precision 3.6-> float(305450479) +...with precision 2.1e1-> float(305450479) +...with precision -> float(305450479) +...with precision 1-> float(305450479) +...with precision -> float(305450479) +===Done===
\ No newline at end of file |