bcscale
Description
Syntax
Set default scale:
bcscale( int $scale ): int
Get default scale:
bcscale( null $scale = null ): int
Parameters
scale
Sets the number of digits after the decimal place.
Return
Returns the old scale when it is used as a setter; otherwise, the current scale is returned.
Examples
1 · void
<? $return = bcscale(); echo $return; ?>
0
2 · scale · current
<? $scale = 6; bcscale($scale); $return = bcscale(); echo $return; ?>
6
3 · scale · old
<? $scale = 2; bcscale($scale); $scale = 6; $return = bcscale($scale); echo $return; ?>
2
4 · bcadd bcsub bcmul bcdiv bcmod
<? $scale = 6; bcscale($scale); $num1 = '1.234'; $num2 = '5'; $bcadd = bcadd($num1, $num2); $bcsub = bcsub($num1, $num2); $bcmul = bcmul($num1, $num2); $bcdiv = bcdiv($num1, $num2); $bcmod = bcmod($num1, $num2); var_dump($bcadd, $bcsub, $bcmul, $bcdiv, $bcmod); ?>
string(8) "6.234000" string(9) "-3.766000" string(8) "6.170000" string(8) "0.246800" string(8) "1.234000"