日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

php数学函数,加(bcadd)、减(bcsub)、乘(bcmul)、除(bcdiv)

發布時間:2024/9/18 22 生活家
生活随笔 收集整理的這篇文章主要介紹了 php数学函数,加(bcadd)、减(bcsub)、乘(bcmul)、除(bcdiv) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

php數學函數,加(bcadd)、減(bcsub)、乘(bcmul)、除(bcdiv)

bcscale() 來設置全局默認的小數位數

bcscale ( int $scale ) : bool

設置所有bc數學函數的未設定情況下得小數點保留位數.

bcadd — 2個任意精度數字的加法計算

左操作數和右操作數求和 ,scale 用于設置結果中小數點后的小數位數。

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

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

bccomp—比較兩個任意精度的數字

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

<?phpechobccomp('1','2')."
";//-1
echobccomp('1.00001','1',3);//0
echobccomp('1.00001','1',5);//1
?>

bcdiv—2個任意精度的數字除法計算

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

<?php
//defaultscale:3
bcscale(3);
echobcdiv('105','6.55957');//16.007
//thisisthesamewithoutbcscale()
echobcdiv('105','6.55957',3);//16.007
?>

bcmod—對一個任意精度數字取模

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

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

bcmul—2個任意精度數字乘法計算

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

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

bcpow—任意精度數字的乘方

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

<?php
echobcpow('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);//
$aand$bareequaltoeachother.
?>

bcscale—設置所有bc數學函數的默認小數點保留位數

bcscale(int$scale) :bool

<?php//default
scale:3
bcscale(3);
echobcdiv('105','6.55957');//16.007//thisisthesamewithout
bcscale()
echobcdiv('105','6.55957',3);//16.007
?>

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

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

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

bcsub—2個任意精度數字的減法

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

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

總結

以上是生活随笔為你收集整理的php数学函数,加(bcadd)、减(bcsub)、乘(bcmul)、除(bcdiv)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。