mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Don't reintroduce split_bc_num()
This function has been removed in870ed5106d
, because it is not necessary to manipulate the `bc_num` itself; instead we simply omit extraneous decimals when converting the number to string. This resolves the issue introduced by24fd49fbab
in a cleaner way than121d193514
.
This commit is contained in:
parent
35e2984b91
commit
512b6c74be
1 changed files with 1 additions and 20 deletions
|
@ -208,21 +208,6 @@ static void php_str2num(bc_num *num, char *str)
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
/* {{{ split_bc_num
|
|
||||||
Convert to bc_num detecting scale */
|
|
||||||
static bc_num split_bc_num(bc_num num) {
|
|
||||||
bc_num newnum;
|
|
||||||
if (num->n_refs >= 1) {
|
|
||||||
return num;
|
|
||||||
}
|
|
||||||
newnum = _bc_new_num_ex(0, 0, 0);
|
|
||||||
*newnum = *num;
|
|
||||||
newnum->n_refs = 1;
|
|
||||||
num->n_refs--;
|
|
||||||
return newnum;
|
|
||||||
}
|
|
||||||
/* }}} */
|
|
||||||
|
|
||||||
/* {{{ proto string bcadd(string left_operand, string right_operand [, int scale])
|
/* {{{ proto string bcadd(string left_operand, string right_operand [, int scale])
|
||||||
Returns the sum of two arbitrary precision numbers */
|
Returns the sum of two arbitrary precision numbers */
|
||||||
PHP_FUNCTION(bcadd)
|
PHP_FUNCTION(bcadd)
|
||||||
|
@ -398,11 +383,7 @@ PHP_FUNCTION(bcmod)
|
||||||
|
|
||||||
switch (bc_modulo(first, second, &result, scale)) {
|
switch (bc_modulo(first, second, &result, scale)) {
|
||||||
case 0:
|
case 0:
|
||||||
if (result->n_scale > scale) {
|
RETVAL_STR(bc_num2str_ex(result, scale));
|
||||||
result = split_bc_num(result);
|
|
||||||
result->n_scale = scale;
|
|
||||||
}
|
|
||||||
RETVAL_STR(bc_num2str(result));
|
|
||||||
break;
|
break;
|
||||||
case -1:
|
case -1:
|
||||||
php_error_docref(NULL, E_WARNING, "Division by zero");
|
php_error_docref(NULL, E_WARNING, "Division by zero");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue