PHP BC High Accuracy function library

Source: Internet
Author: User
Tags modulus square root


<?php *************************************************************************************** *php BC High accuracy function Library * php BC Math contains: Add, compare, divide, subtract, balance, multiply, n-squared, configure default decimal number, squared * These functions are useful when it comes to the calculation of money ***************************************** *********************************************** **************************************************************** * Two high-precision number comparison * encountered in the work of a situation, 0.00!  = 0 *int Bccomp (string $left _operand, String $right _operand [, int $scale]) * $left = $right returns 0 * $left < $right return-1 * $left > $right returns 1 * $scale the number of decimal places ******************************************************************************* $a = 4.45; $b = 5.54;if (Bccomp ($a, $b, 2) = = 0) {} ************************************************************* * Two high-precision numbers added *string bcadd (String $left _operand, String $right _operand [, int $scale]) * $scal E returns the number of decimal points *************************************************************************************** $a = 1.0321456;$ b = 0.01234$c = Bcadd ($a, $b, 2);//var_dump ($c); * Two high-precision number subtraction *sstring bcsub ( String $left _operand, String $right _operand [, int $scale]) * $scale the number of decimal points returned ****************************************** $a = 1.0321456; $b = 3.0123456; $c = bcsub ($a, $b, 2); Var_dump ($c); * Two high-precision numbers for remainder/modulus *string bcmod (String $left _operand, String $ modulus) ******************************************************* $a = 6; $b = 4; $c = Bcmod ($a, $b);//var_dump ($c); * Two high-precision numbers divide *string bcdiv ( String $left _operand, String $right _operand [, int $scale]) * $scale The default number of decimal places is 0 ***************************************** $a = 6; $b = 5; $c = Bcdiv ($a, $b, 3); Var_dump ($c); ****************************************** Two high-precision numbers multiply *string bcmul (String $left _operand, String $right _operand [, int $scale]) * $scale The default number of decimal places is 0 *********************************************************************************** $a = 3.1415926; $b = 2.4569874566; $c = Bcmul ($a, $b, 6);//var_dump ($c); * Two high-precision number of the second square value *string Bcpow (String $left _operand, String $right _operand [, int $scale]) * $scale The default number of decimal places is 0 *************************************** $a = 3.1415926; $b = 2; $c = Bcpow ($a, $b, 3);//var_dump ($c); * The square root of the *string bcsqrt (string $operand [, int $scale]) * $scale decimal number The number of points by default is 0 *************************************************** $b = bcsqrt ($a, 6);//var_dump ($b); * Set the number of decimal places for the BC function *bool bcscale (int $scale) * $scale The default number of decimal places is 0 **************************** **//bcsCale ();?  >


PHP BC High Accuracy function library

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.