<?php
string bcsub ( string $num1,
string $num2,
?int $scale = null )
where,
$num1 = The left operand as STRING
$num2 = The right operand as STRING
$scale = The number of decimal places
considered by this operation
?>
<?php
$vl01a = 2020.106;
$vl01b = 0.237;
$sc01a = 0;
$sc01b = 10;
$bca01a = bcsub($vl01a, $vl01b);
$bca01b1 = bcsub($vl01a, $vl01b, $sc01a);
$bca01b2 = bcsub($vl01a, $vl01b, $sc01b);
echo 'bcsub( ' . $vl01a . ', ' . $vl01b . ' ) = ' . $bca01a .
'<br>[ NO SCALE IS PROVIDED ]<br><br>';
echo 'bcsub( ' . $vl01a . ', ' . $vl01b . ', ' . $sc01a . ' ) = ' . $bca01b1 .
'<br>[ SCALE = ' . $sc01a . ' ]<br><br>';
echo 'bcsub( ' . $vl01a . ', ' . $vl01b . ', ' . $sc01b . ' ) = ' . $bca01b2 .
'<br> [ SCALE = ' . $sc01b . ' ]<br><br>';
?>
<?php
$vl02a = 0.237;
$vl02b = 2020.106;
$sc02a = 0;
$sc02b = 10;
$bca02a = bcsub($vl02a, $vl02b);
$bca02b1 = bcsub($vl02a, $vl02b, $sc02a);
$bca02b2 = bcsub($vl02a, $vl02b, $sc02b);
echo 'bcsub( ' . $vl02a . ', ' . $vl02b . ' ) = ' . $bca02a .
'<br>[ NO SCALE IS PROVIDED ]<br><br>';
echo 'bcsub( ' . $vl02a . ', ' . $vl02b . ', ' . $sc02a . ' ) = ' . $bca02b1 .
'<br>[ SCALE = ' . $sc02a . ' ]<br><br>';
echo 'bcsub( ' . $vl02a . ', ' . $vl02b . ', ' . $sc02b . ' ) = ' . $bca02b2 .
'<br> [ SCALE = ' . $sc02b . ' ]<br><br>';
?>