mirror of
https://github.com/php/php-src.git
synced 2026-03-24 08:12:21 +01:00
Added BcMath\Number class. It is an immutable object, has methods that are equivalent to existing BCMath calculation functions, and can also be calculated using operators. The existing BCMath function returned a string for each calculation, but this class returns an object. RFC: https://wiki.php.net/rfc/support_object_type_in_bcmath, https://wiki.php.net/rfc/fix_up_bcmath_number_class --------- Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
33 lines
680 B
PHP
33 lines
680 B
PHP
--TEST--
|
|
BcMath\Number serialize
|
|
--EXTENSIONS--
|
|
bcmath
|
|
--FILE--
|
|
<?php
|
|
|
|
$values = [
|
|
'0',
|
|
'0.0',
|
|
'2',
|
|
'1234',
|
|
'12.0004',
|
|
'0.1230',
|
|
1,
|
|
12345,
|
|
];
|
|
|
|
foreach ($values as $value) {
|
|
$num = new BcMath\Number($value);
|
|
echo serialize($num) . "\n";
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
O:13:"BcMath\Number":1:{s:5:"value";s:1:"0";}
|
|
O:13:"BcMath\Number":1:{s:5:"value";s:3:"0.0";}
|
|
O:13:"BcMath\Number":1:{s:5:"value";s:1:"2";}
|
|
O:13:"BcMath\Number":1:{s:5:"value";s:4:"1234";}
|
|
O:13:"BcMath\Number":1:{s:5:"value";s:7:"12.0004";}
|
|
O:13:"BcMath\Number":1:{s:5:"value";s:6:"0.1230";}
|
|
O:13:"BcMath\Number":1:{s:5:"value";s:1:"1";}
|
|
O:13:"BcMath\Number":1:{s:5:"value";s:5:"12345";}
|