What is the usage of php bcadd

藏色散人
Release: 2023-03-10 15:30:01
Original
5790 people have browsed it

php bcadd is used for the addition calculation of two arbitrary precision numbers. Its usage syntax is "bcadd ( string $num1 , string $num2 , int|null $scale = null ) : string", which means that num1 and num2 summation.

What is the usage of php bcadd

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

What is the usage of php bcadd?

bcadd — Addition of two arbitrary precision numbers

Description

bcadd ( string $num1 , string $num2 , int|null $scale = null ) : string
Copy after login

Sum num1 and num2.

Parameters

num1
Copy after login

Left operand, string type.

num2
Copy after login

Right operand, string type.

scale
Copy after login

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

Returns the result of the sum of the two operands as a string.

Change log

Version

8.0.0 Now scale can be null.

Example

Example #1 bcadd() Example

<?php
$a = &#39;1.234&#39;;
$b = &#39;5&#39;;
echo bcadd($a, $b);     // 6
echo bcadd($a, $b, 4);  // 6.2340
?>
Copy after login

See

bcsub() - Subtraction of two arbitrary precision numbers

Recommended learning: "PHP video tutorial"

The above is the detailed content of What is the usage of php bcadd. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template