PHP | bcscale() Function

The bcscale() function is an inbuilt function in PHP. It sets the default scale parameters for all bc math function calls. When we call the function bcscale() in a program, the parameter passed in this function thus becomes the default scale factor which by default is zero.
Syntax:
int bcscale($scale)
Parameters: This function accepts a single parameter $scale and is of int type and is mandatory. This parameter tells the number of digits that will appear after the decimal in the result of function call of all bc math functions. Its default value is zero.
Return Value: This function returns the old scale value.
Below programs illustrate the bcscale() function in PHP :
Program 1:
<?php // default scale : 3 bcscale(3); // takes the default scale value as 3 // which is declared at the beginning echo bcadd('111', '6.55957'), "\n"; // 16.007 // this is not the same without bcscale() echo bcadd('111', '6.55957', 1), "\n"; // 16.007 // takes the default scale value as 3 // which is declared at the beginning echo bcadd('111', '6.55957'), "\n"; ?> |
Output:
117.559 117.5 117.559
Program 2:
<?php // default scale : 3 bcscale(5); // takes the default scale value as 3 // which is declared at the beginning echo bcadd('111', '6.55957'), "\n"; // 16.007 // this is not the same without bcscale() echo bcadd('111', '6.55957', 1), "\n"; // 16.007 // default scale value changes bcscale(2); // takes the default scale value as 2 // which is declared echo bcadd('111', '6.55957'), "\n"; ?> |
Output:
117.55957 117.5 117.55
<!–
–>

How to get the function name inside a function in PHP ?

PHP 5 vs PHP 7

PHP | Get PHP configuration information using phpinfo()

PHP | php.ini File Configuration

How to import config.php file in a PHP script ?

How to include content of a PHP file into another PHP file ?

PHP | imagecreatetruecolor() Function

PHP fpassthru( ) Function

PHP | ImagickDraw getTextAlignment() Function

PHP | Ds\Sequence last() Function



Please Login to comment…