Php BC high-precision function library and bc precision function library
<? Php *************************************** **************************************** * ******* php BC high-precision function library * php bc math contains: add, compare, divide, subtract, remainder, multiply, n, configure the default number of decimal places, square * these functions are useful when it comes to money-related computing ************************** **************************************** **************************************** **************************************** * ***************************** comparison of two high-precision numbers * situation, 0.00! = 0 * int bccomp (string $ left_operand, string $ right_operand [, int $ scale]) * $ left = $ right returns 0 * $ left <$ right returns-1 * $ left> $ right returns 1 * $ scale decimal place ********** **************************************** ************************************ $ a = 4.45; $ B = 5.54; if (bccomp ($ a, $ B, 2) = 0) {}************************************** **************************************** * ******** add two high-precision numbers * string bcadd (String $ left_operand, string $ right_operand [, int $ scale]) * $ scale returns the number of decimal places ********************************** **************************************** * ************ $ a = 1.0321456; $ B = 0.0123456; $ c = bcadd ($ a, $ B, 2); // var_dump ($ c ); **************************************** **************************************** * ****** subtraction of two high-precision numbers * sstring bcsub (string $ left_operand, string $ right_operand [, Int $ scale]) * $ scale returns the number of decimal places ********************************** **************************************** * ************ $ a = 1.0321456; $ B = 3.0123456; $ c = bcsub ($ a, $ B, 2); var_dump ($ c ); **************************************** * **************** remainder/modulo of two high-precision computations * string bcmod (string $ left_operand, string $ modulus) **************************************** * ************** $ a = 6; $ B = 4; $ c = bcmod ($ a, $ B); // Var_dump ($ c ); **************************************** **************************************** * ****** division of two high-precision numbers * string bcdiv (string $ left_operand, string $ right_operand [, int $ scale]) * $ scale indicates the number of decimal places. The default value is 0 ******************************** **************************************** * ************** $ a = 6; $ B = 5; $ c = bcdiv ($ a, $ B, 3); // var_dump ($ c ); **************************************** ***** **************************************** * ** Multiply two high-precision numbers * string bcmul (string $ left_operand, string $ right_operand [, int $ scale]) * $ scale indicates the number of decimal places. The default value is 0 ******************************** **************************************** * ************** $ a = 3.1415926; $ B = 2.4569874566; $ c = bcmul ($ a, $ B, 6); // var_dump ($ c ); **************************************** **************************************** * ******* two highs The power of the number of precision * string bcpow (string $ left_operand, string $ right_operand [, int $ scale]) * $ scale indicates the number of decimal places. The default value is 0 ******************************** **************************************** * ************** $ a = 3.1415926; $ B = 2; $ c = bcpow ($ a, $ B, 3); // var_dump ($ c ); **************************************** * ********* calculate the square root of a precise number * string bcsqrt (string $ operand [, int $ scale]) * $ scale the number of decimal places is 0 by default ***************** * ********************************* $ B = bcsqrt ($ a, 6); // var_dump ($ B ); * ***************************** set the decimal point of the bc function * bool bcscale (int $ scale) * $ scale the number of decimal places is 0 ******************************// bcscale () ;?>