php 精准计算模块bcmath

WBOY
Release: 2016-06-23 13:50:00
Original
1807 people have browsed it

bc是Binary Calculator的缩写。bc*函数的参数都是操作数加上一个可选的 [int scale],比如string bcadd(string $left_operand, string $right_operand[, int $scale]),如果scale没有提供,就用bcscale的缺省值。这里大数直接用一个由0-9组成的string表示,计算结果返回的也是一个 string。
 
 
bcadd ? 将两个高精度数字相加 
bccomp ? 比较两个高精度数字,返回-1, 0, 1 
bcdiv ? 将两个高精度数字相除 
bcmod ? 求高精度数字余数 
bcmul ? 将两个高精度数字相乘 
bcpow ? 求高精度数字乘方 
bcpowmod ? 求高精度数字乘方求模,数论里非常常用 
bcscale ? 配置默认小数点位数,相当于就是Linux bc中的”scale=” 
bcsqrt ? 求高精度数字平方根 

bcsub ? 将两个高精度数字相减

windows下直接修改php.ini配置文件

[bcmath]; Number of decimal digits for all bcmath functions.; http://php.net/bcmath.scalebcmath.scale = <strong>1</strong>
Copy after login
然后重启apache。

linux下需要重新编译apache

Related labels:
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