首页 » 网站推广 » phpbcmul技巧_php数学函数加bcadd减bcsub乘bcmul除bcdiv

phpbcmul技巧_php数学函数加bcadd减bcsub乘bcmul除bcdiv

访客 2024-10-24 0

扫一扫用手机浏览

文章目录 [+]

bcscale ( int $scale ) : bool

设置所有bc数学函数的未设定情形下得小数点保留位数.

phpbcmul技巧_php数学函数加bcadd减bcsub乘bcmul除bcdiv

bcadd — 2个任意精度数字的加法打算

phpbcmul技巧_php数学函数加bcadd减bcsub乘bcmul除bcdiv
(图片来自网络侵删)

左操作数和右操作数求和 ,scale 用于设置结果中小数点后的小数位数。

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

<?php$a = '1.234';$b = '5'; echo bcadd($a, $b); // 6 echo bcadd($a, $b, 4); // 6.2340?>

bccomp — 比较两个任意精度的数字

bccomp ( string $left_operand , string $right_operand [, int $scale = int ] ) : int

<?phpecho bccomp('1', '2') . "\n"; // -1 echo bccomp('1.00001', '1', 3); // 0 echo bccomp('1.00001', '1', 5); // 1?>

bcdiv — 2个任意精度的数字除法打算

bcdiv ( string $left_operand , string $right_operand [, int $scale = int ] ) : string

<?php// default scale : 3 bcscale(3); echo bcdiv('105', '6.55957'); // 16.007// this is the same without bcscale() echo bcdiv('105', '6.55957', 3); // 16.007?>

bcmod — 对一个任意精度数字取模

bcmod ( string $left_operand , string $modulus ) : string

<?php echo bcmod('4', '2'); // 0 echo bcmod('2', '4'); // 2?>

bcmul — 2个任意精度数字乘法打算

bcmul ( string $left_operand , string $right_operand [, int $scale = int ] ) : string

<?php echo bcmul('1.34747474747', '35', 3); // 47.161 echo bcmul('2', '4'); // 8?>

bcpow — 任意精度数字的乘方

bcpow ( string $left_operand , string $right_operand [, int $scale ] ) : string

<?php echo bcpow('4.2', '3', 2); // 74.08?>

bcpowmod----将任意的精确数提高到另一个,再用指定的模量还原

bcpowmod ( string $base , string $exponent , string $modulus [, int $scale = 0 ] ) : string

<?php $a = bcpowmod($x, $y, $mod); $b = bcmod(bcpow($x, $y), $mod);// $a and $b are equal to each other.?>

bcscale — 设置所有bc数学函数的默认小数点保留位数

bcscale ( int $scale ) : bool

<?php// default scale : 3 bcscale(3); echo bcdiv('105', '6.55957'); // 16.007// this is the same without bcscale() echo bcdiv('105', '6.55957', 3); // 16.007?>

bcsqrt — 任意精度数字的二次方根

bcsqrt ( string $operand [, int $scale ] ) : string

<?php echo bcsqrt('2', 3); // 1.414?>

bcsub — 2个任意精度数字的减法

bcsub ( string $left_operand , string $right_operand [, int $scale = int ] ) : string

<?php $a = '1.234'; $b = '5'; echo bcsub($a, $b); // -3 echo bcsub($a, $b, 4); // -3.7660?>

标签:

相关文章

招商蛇口中国房地产龙头企业,未来可期

招商蛇口(股票代码:001979),作为中国房地产企业的领军企业,自成立以来始终秉持“以人为本,追求卓越”的经营理念,致力于打造高...

网站推广 2025-02-18 阅读1 评论0