mirror of
https://github.com/php/php-src.git
synced 2025-08-18 06:58:55 +02:00

We change `bcmul()` and `bcpow()` so that the result has exactly the requested scale (i.e. decimal places) to make them consistent with the other BCMath functions. This also changes our stance regarding bug #52748, which had been classified as documentation problem. We do not manipulate the numbers themselves (anymore), but rather introduce `bc_num2str_ex()` which accepts a scale parameter that overrides the scale of the number by omitting extraneous decimals and adding zeros, respectively. This also allows us to get rid of `split_bc_num()`, which fixes bug #75164 as well.
29 lines
675 B
PHP
29 lines
675 B
PHP
--TEST--
|
|
BCMath functions return result with default scale
|
|
--SKIPIF--
|
|
<?php
|
|
if (!extension_loaded('bcmath')) die('skip bcmath extension not available');
|
|
?>
|
|
--INI--
|
|
bcmath.scale = 5
|
|
--FILE--
|
|
<?php
|
|
echo
|
|
'bcadd: ', bcadd('2', '1'), PHP_EOL,
|
|
'bcdiv: ', bcdiv('2', '1'), PHP_EOL,
|
|
'bcmul: ', bcmul('2', '1'), PHP_EOL,
|
|
'bcpow: ', bcpow('2', '1'), PHP_EOL,
|
|
'bcpowmod: ', bcpowmod('2', '1', '3'), PHP_EOL,
|
|
'bcsqrt: ', bcsqrt('4'), PHP_EOL,
|
|
'bcsub: ', bcsub('2', '1'), PHP_EOL;
|
|
?>
|
|
===DONE===
|
|
--EXPECT--
|
|
bcadd: 3.00000
|
|
bcdiv: 2.00000
|
|
bcmul: 2.00000
|
|
bcpow: 2.00000
|
|
bcpowmod: 2.00000
|
|
bcsqrt: 2.00000
|
|
bcsub: 1.00000
|
|
===DONE===
|