bcadd Add two arbitrary precision numbers php函数


bcadd

(PHP 4, PHP 5)

bcaddAdd two arbitrary precision numbers

说明

string bcadd ( string $left_operand , string $right_operand [, int $scale ] )

Sums left_operand and right_operand.

参数

left_operand

The left operand, as a string.

right_operand

The right operand, as a string.

scale

此可选参数用于设置结果中小数点后的小数位数。 也可通过使用 bcscale() 来设置全局默认的小数位数,用于所有函数。

返回值

The sum of the two operands, as a string.

范例

Example #1 bcadd() example

<?php

$a 
'1.234';
$b '5';

echo 
bcadd($a$b);     // 6
echo bcadd($a$b4);  // 6.2340

?>

参见

  • bcsub() - Subtract one arbitrary precision number from another



相关阅读:
bccomp Compare two arbitrary precision numbers
bcdiv Divide two arbitrary precision numbers
bcmod Get modulus of an arbitrary precision number
bcmul Multiply two arbitrary precision number
bcpow Raise an arbitrary precision number to another
bcpowmod Raise an arbitrary precision number to another, reduced by a specified modulus
bcscale Set default scale parameter for all bc math functions
bcsqrt Get the square root of an arbitrary precision number
bcsub Subtract one arbitrary precision number from another
bin2hex 将二进制数据转换成十六进制表示
bindec 二进制转换为十进制
bindtextdomain Sets the path for a domain
bind_textdomain_codeset Specify the character encoding in which the messages from the DOMAIN message catalog will be returned
bzclose Close a bzip2 file
快速导航

Copyright © 2016 phpStudy |