mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
parent
35189d2dd6
commit
1e3435b289
2 changed files with 27 additions and 5 deletions
|
@ -537,15 +537,19 @@ PHP_FUNCTION(bccomp)
|
|||
Sets default scale parameter for all bc math functions */
|
||||
PHP_FUNCTION(bcscale)
|
||||
{
|
||||
long new_scale;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &new_scale) == FAILURE) {
|
||||
long old_scale, new_scale;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &new_scale) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
BCG(bc_precision) = ((int)new_scale < 0) ? 0 : new_scale;
|
||||
old_scale = BCG(bc_precision);
|
||||
|
||||
RETURN_TRUE;
|
||||
if (ZEND_NUM_ARGS() == 1) {
|
||||
BCG(bc_precision) = ((int)new_scale < 0) ? 0 : new_scale;
|
||||
}
|
||||
|
||||
RETURN_LONG(old_scale);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
|
18
ext/bcmath/tests/bcscale_variation003.phpt
Normal file
18
ext/bcmath/tests/bcscale_variation003.phpt
Normal file
|
@ -0,0 +1,18 @@
|
|||
--TEST--
|
||||
bcscale() return value
|
||||
--SKIPIF--
|
||||
<?php if(!extension_loaded("bcmath")) print "skip"; ?>
|
||||
--INI--
|
||||
bcmath.scale=0
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump(bcscale(1));
|
||||
var_dump(bcscale(4));
|
||||
var_dump(bcscale());
|
||||
var_dump(bcscale());
|
||||
?>
|
||||
--EXPECT--
|
||||
int(0)
|
||||
int(1)
|
||||
int(4)
|
||||
int(4)
|
Loading…
Add table
Add a link
Reference in a new issue