The problem of how to accurately calculate PHP floating-point numbers
This article mainly explains the "how to accurately calculate PHP floating point problem", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's train of thought slowly in depth, together to study and learn "how to accurately calculate PHP floating point problem" bar!
Php: BCMath
Bc is the abbreviation of Binary Calculator. The arguments to the bc* function are operands plus an optional [int scale], such as string bcadd (stringleftoperand, stringleftoperand,stringright_operand [, int $scale]). If scale does not provide it, the default value of bcscale is used. Here, the large number is directly represented by a string consisting of 0-9, and the result of the calculation also returns a string.
Bcadd-add two high-precision numbers
Bccomp-compare two high-precision numbers and return-1, 0, 1
Bcdiv-divides two high-precision numbers
Bcmod-finding high precision digital remainder
Bcmul-multiplies two high-precision numbers
Bcpow-finding the High Precision Digital multiplier
Bcpowmod-find high-precision digital multiplier and module, which is not often used in number theory.
Bcscale-configure the default number of decimal places, which is equivalent to "scale=" in Linux bc
Bcsqrt-finding the square root of high precision numbers
Bcsub-subtract two high-precision digits
First, take a look at a piece of code: