bcsub
Description
Syntax
bcsub( 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 subtraction, as a string.
Examples
1 · num1 num2
<? $num1 = "1.234"; $num2 = "5"; $return = bcsub($num1, $num2); var_dump($return);
string(2) "-3"
2 · scale
<? $num1 = "1.234"; $num2 = "5"; $scale = 6; $return = bcsub($num1, $num2, $scale); var_dump($return);
string(9) "-3.766000"
3 · bcscale
<? $scale = 6; bcscale($scale); $num1 = "1.234"; $num2 = "5"; $return = bcsub($num1, $num2); var_dump($return);
string(9) "-3.766000"