private static function performCalc($number1, $action, $number2, $round, $decimals, $precision)
    {
        $result = null;
        $compare = false;
        switch ($action) {
            case '+':
                $result = (self::$blnBcmath) ? bcadd($number1, $number2, $precision) /* string */ : ($number1 + $number2);
                break;
            case '-':
                $result = (self::$blnBcmath) ? bcsub($number1, $number2, $precision) /* string */ : ($number1 - $number2);
                break;
            case '*':
                $result = (self::$blnBcmath) ? bcmul($number1, $number2, $precision) /* string */ : ($number1 * $number2);
                break;
            case 'sqrt':
                $result = (self::$blnBcmath) ? bcsqrt($number1, $precision) /* string */ : sqrt($number1);
                break;
            case '/':
                if ($number2 > 0) {
                    if (self::$blnBcmath) {
                        $result = bcdiv($number1, $number2, $precision); // string, or NULL if right_operand is 0
                    } else if ($number2 != 0) {
                        $result = $number1 / $number2;
                    }
                }

                if (!isset($result)) {
                    $result = 0;
                }
                break;
            case '%':
                if (self::$blnBcmath) {
                    $result = bcmod($number1, $number2); // string, or NULL if modulus is 0.
                } else if ($number2 != 0) {
                    $result = $number1 % $number2;
                }

                if (!isset($result)) {
                    $result = 0;
                }
                break;
            case '=':
                $compare = true;
                if (self::$blnBcmath) {
                    $result = bccomp($number1, $number2, $precision); // returns int 0, 1 or -1
                } else {
                    $result = ($number1 == $number2) ? 0 : (($number1 > $number2) ? 1 : -1);
                }
                break;
        }

        if (isset($result)) {
            if ($compare === false) {
                if ($round === true) {
                    $result = round(floatval($result), $decimals);
                    if ($decimals === 0) {
                        $result = (int) $result;
                    }
                } else {
                    $result = (intval($result) == $result) ? intval($result) : floatval($result);
                }
            }
            return $result;
        }

        return false;
    }
private static function performCalc($number1, $action, $number2, $round, $decimals, $precision)
    {
        $result = null;
        $compare = false;
        switch ($action) {
            case '+':
                $result = (self::$blnBcmath) ? bcadd($number1, $number2, $precision) /* string */ : ($number1 + $number2);
                break;
            case '-':
                $result = (self::$blnBcmath) ? bcsub($number1, $number2, $precision) /* string */ : ($number1 - $number2);
                break;
            case '*':
                $result = (self::$blnBcmath) ? bcmul($number1, $number2, $precision) /* string */ : ($number1 * $number2);
                break;
            case 'sqrt':
                $result = (self::$blnBcmath) ? bcsqrt($number1, $precision) /* string */ : sqrt($number1);
                break;
            case '/':
                if ($number2 > 0) {
                    if (self::$blnBcmath) {
                        $result = bcdiv($number1, $number2, $precision); // string, or NULL if right_operand is 0
                    } else if ($number2 != 0) {
                        $result = $number1 / $number2;
                    }
                }

                if (!isset($result)) {
                    $result = 0;
                }
                break;
            case '%':
                if (self::$blnBcmath) {
                    $result = bcmod($number1, $number2); // string, or NULL if modulus is 0.
                } else if ($number2 != 0) {
                    $result = $number1 % $number2;
                }

                if (!isset($result)) {
                    $result = 0;
                }
                break;
            case '=':
                $compare = true;
                if (self::$blnBcmath) {
                    $result = bccomp($number1, $number2, $precision); // returns int 0, 1 or -1
                } else {
                    $result = ($number1 == $number2) ? 0 : (($number1 > $number2) ? 1 : -1);
                }
                break;
        }

        if (isset($result)) {
            if ($compare === false) {
                if ($round === true) {
                    $result = round(floatval($result), $decimals);
                    if ($decimals === 0) {
                        $result = (int) $result;
                    }
                } else {
                    $result = (intval($result) == $result) ? intval($result) : floatval($result);
                }
            }
            return $result;
        }

        return false;
    }
private static function performCalc ( $ number1 , $ action , $ number2 , $ round , $ decimals , $ precision ) { $ result = null ; $ compare = false ; switch ( $ action ) { case '+' : $ result = ( self :: $ blnBcmath ) ? bcadd ( $ number1 , $ number2 , $ precision ) /* string */ : ( $ number1 + $ number2 ) ; break ; case '-' : $ result = ( self :: $ blnBcmath ) ? bcsub ( $ number1 , $ number2 , $ precision ) /* string */ : ( $ number1 - $ number2 ) ; break ; case '*' : $ result = ( self :: $ blnBcmath ) ? bcmul ( $ number1 , $ number2 , $ precision ) /* string */ : ( $ number1 * $ number2 ) ; break ; case 'sqrt' : $ result = ( self :: $ blnBcmath ) ? bcsqrt ( $ number1 , $ precision ) /* string */ : sqrt ( $ number1 ) ; break ; case '/' : if ( $ number2 > 0 ) { if ( self :: $ blnBcmath ) { $ result = bcdiv ( $ number1 , $ number2 , $ precision ) ; // string, or NULL if right_operand is 0 } else if ( $ number2 != 0 ) { $ result = $ number1 / $ number2 ; } } if ( ! isset ( $ result ) ) { $ result = 0 ; } break ; case '%' : if ( self :: $ blnBcmath ) { $ result = bcmod ( $ number1 , $ number2 ) ; // string, or NULL if modulus is 0. } else if ( $ number2 != 0 ) { $ result = $ number1 % $ number2 ; } if ( ! isset ( $ result ) ) { $ result = 0 ; } break ; case '=' : $ compare = true ; if ( self :: $ blnBcmath ) { $ result = bccomp ( $ number1 , $ number2 , $ precision ) ; // returns int 0, 1 or -1 } else { $ result = ( $ number1 == $ number2 ) ? 0 : ( ( $ number1 > $ number2 ) ? 1 : - 1 ) ; } break ; } if ( isset ( $ result ) ) { if ( $ compare === false ) { if ( $ round === true ) { $ result = round ( floatval ( $ result ) , $ decimals ) ; if ( $ decimals === 0 ) { $ result = ( int ) $ result ; } } else { $ result = ( intval ( $ result ) == $ result ) ? intval ( $ result ) : floatval ( $ result ) ; } } return $ result ; } return false ; }
Function which performs calculation.
@param  string|integer|float|boolean $number1 See bcCalc description
@param  string $action See bcCalc description
@param  string|integer|float|boolean $number2 See bcCalc description
@param  boolean $round See bcCalc description
@param  integer $decimals See bcCalc description
@param  integer $precision See bcCalc description
@return integer|float|boolean
Function which performs calculation .