Пример #1
0
--TEST--
php\lib\num Test convert
--FILE--
<?php 
use php\lib\num;
var_dump(num::toBin(100500));
var_dump(num::toHex(100500));
var_dump(num::toOctal(100500));
var_dump(num::toString(100500, 5));
echo "--test-decode\n";
var_dump(num::decode('0x18894'));
var_dump(num::decode('0304224'));
?>
--EXPECT--
string(17) "11000100010010100"
string(5) "18894"
string(6) "304224"
string(8) "11204000"
--test-decode
int(100500)
int(100500)
Пример #2
0
--TEST--
php\lib\num Test format
--FILE--
<?php 
use php\lib\num;
var_dump(num::format(100500900.123456, '###,###', '.', ' '));
var_dump(num::format(100500900.123456, '###,###.000', '.', ' '));
?>
--EXPECT--
string(11) "100 500 900"
string(15) "100 500 900.123"
Пример #3
0
--TEST--
php\lib\num Test compare
--FILE--
<?php 
use php\lib\num;
var_dump(num::compare(3.1, 3));
var_dump(num::compare(3, 3));
var_dump(num::compare(2, 3.1));
echo "--test-strings\n";
var_dump(num::compare('10', 9));
var_dump(num::compare('10', '05'));
var_dump(num::compare('10', '10'));
var_dump(num::compare('3.0', '10'));
?>
--EXPECT--
int(1)
int(0)
int(-1)
--test-strings
int(1)
int(1)
int(0)
int(-1)