php8.5
Home/ Manual/ bc / functions/ bcsub

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

VersionDescription
8.0.0scale 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

Source: reference/bc/functions/bcsub.xml · from the official PHP manual (php/doc-en)