VII. BC math 高精度數學函數

簡介

PHP 為任意精度數學計算提供了二進位計算器(Binary Calculator),它支援任意大小和精度的數字,以字串形式描述。

需求

自 PHP 4.0.4 以來,libbcmath 都綁定在 PHP 內定。本增加不需要其它外部庫的支援。

安裝

本類函數僅在 PHP 編譯時配置了 --enable-bcmath 時可用。在 PHP 3 中,本類函數僅在 PHP 編譯時沒有配置 --disable-bcmath 時可用。

PHP 的 Windows 版本已經內建該增加模組的支援。無需加載任何附加增加庫即可使用這些函數。

運行時配置

這些函數的行為受 php.ini 的影響。

表格 1. BC 數學庫配置選項

名稱預設值可修改範圍更新記錄
bcmath.scale"0"PHP_INI_ALL自 PHP 5.0.0 起可用。
有關 PHP_INI_* 常量進一步的細節與定義參見附錄 G

以下是配置選項的簡要解釋。

bcmath.scale integer

所有 bcmath 函數中十進位數字的數目。參見 bcscale()

資源類型

本增加模組未定義任何資源類型。

預定義常量

本增加模組未定義任何常量。

目錄
bcadd -- Add two arbitrary precision numbers
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