bcsub
PHP function
Edit on GitHub ✎
(PHP 4, PHP 5, PHP 7, PHP 8)
Subtract one arbitrary precision number from another
Description
bcsub(string $num1, string $num2, int|null $scale = null): string
Subtracts num2 from num1.
Return Values
The result of the subtraction, as a string.
Changelog
| Version | Description |
|---|---|
| 8.0.0 | scale is now nullable. |
Examples
bcsub() example
php
<?php
$a = '1.234';
$b = '5';
echo bcsub($a, $b); // -3
echo bcsub($a, $b, 4); // -3.7660
?>See Also
bcadd()BcMath\Number::sub