bcsub is not an extension of PHP, but a built-in function in PHP. The bcsub function accepts two arbitrary precision numbers as strings and returns the subtraction of the two numbers after scaling the result to the specified precision.
The operating environment of this article: Windows 7 system, PHP version 7.1, DELL G3 computer
The bcsub() function in PHP is a built-in function , used to subtract one arbitrary-precision number from another. This function accepts two arbitrary-precision numbers as strings and returns the subtraction of the two numbers after scaling the result to the specified precision.
bcsub — Subtraction of 2 arbitrary-precision numbers
Description
bcsub ( string $left_operand , string $right_operand [, int $scale = int ] ) : string
Subtract the right operand from the left operand.
Parameter
left_operand
The left operand of string type.
right_operand
The right operand of string type.
scale
This optional parameter is used to set the decimal point after the decimal point in the result. Number of decimal places. You can also set a global default number of decimal places for all functions by using bcscale().
Return value
Return the result after subtraction to the string type.
Example
<?php $a = '1.234'; $b = '5'; echo bcsub($a, $b); // -3 echo bcsub($a, $b, 4); // -3.7660 ?>
Recommended study: " PHP video tutorial》
The above is the detailed content of bcsub is a php extension. For more information, please follow other related articles on the PHP Chinese website!