bcadd
Description
Syntax
bcadd( string $num1, string $num2, ?int $scale = null ): string
Parameters
num1
The left operand, as a string.
num2
The right operand, as a string.
scale
Sets the number of digits after the decimal place in the result.
If omitted, it will default to the scale set globally with the bcscale() function, or fallback to 0 if this has not been set.
Return
Returns the result of the addition, as a string.
Examples
1 · num1 num2
<? $num1 = '1.234'; $num2 = '5'; $return = bcadd($num1, $num2); echo $return;
6
2 · scale
<? $num1 = '1.234'; $num2 = '5'; $scale = 6; $return = bcadd($num1, $num2, $scale); echo $return;
6.234000
3 · bcscale
<? $scale = 6; bcscale($scale); $num1 = '1.234'; $num2 = '5'; $return = bcadd($num1, $num2); echo $return;
6.234000