bcadd is a function in PHP. Its function is to calculate the addition of two arbitrary precision numbers. The syntax of this function is such as "bcadd(string $num1, string $num2, ?int $scale = null): string".
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
Is bcadd php a function or an extension?
bcadd
is a function in php.
bcadd: Addition calculation of two arbitrary precision numbers
Description
bcadd(string $num1, string $num2, ?int $scale = null): string
Sum num1 and num2.
Parameters:
num, left operand, string type.
num2, right operand, string type.
scale, this optional parameter is used to set the number of decimal places after the decimal point in the result. You can also set a global default number of decimal places for all functions by using bcscale(). If not set, defaults to 0.
Return value: Return the result of the sum of the two operands as a string.
Change log: 8.0.0 scale can now be null.
Example: bcadd() Example
<?php $a = '1.234'; $b = '5'; echo bcadd($a, $b); // 6 echo bcadd($a, $b, 4); // 6.2340 ?>
Related introduction:
bcsub() - Subtraction of two arbitrary precision numbers
Recommended learning:《PHP video tutorial》
The above is the detailed content of Is bcadd php a function or an extension?. For more information, please follow other related articles on the PHP Chinese website!