public static function compare($amountA, $amountB)
    {
        $precision = (int) self::config()->get('precision');
        if (function_exists('bccomp') && self::config()->get('useBcMath')) {
            return bccomp($amountA, $amountB, $precision);
        }

        $scale = pow(10, max(0, $precision));
        $a = (int)($scale * $amountA);
        $b = (int)($scale * $amountB);

        return max(-1, min(1, $a - $b));
    }
public static function compare($amountA, $amountB)
    {
        $precision = (int) self::config()->get('precision');
        if (function_exists('bccomp') && self::config()->get('useBcMath')) {
            return bccomp($amountA, $amountB, $precision);
        }

        $scale = pow(10, max(0, $precision));
        $a = (int)($scale * $amountA);
        $b = (int)($scale * $amountB);

        return max(-1, min(1, $a - $b));
    }
public static function compare ( $ amountA , $ amountB ) { $ precision = ( int ) self :: config ( ) -> get ( 'precision' ) ; if ( function_exists ( 'bccomp' ) && self :: config ( ) -> get ( 'useBcMath' ) ) { return bccomp ( $ amountA , $ amountB , $ precision ) ; } $ scale = pow ( 10 , max ( 0 , $ precision ) ) ; $ a = ( int ) ( $ scale * $ amountA ) ; $ b = ( int ) ( $ scale * $ amountB ) ; return max ( - 1 , min ( 1 , $ a - $ b ) ) ; }
Compare two numbers that are represented as a string
@param string $amountA first operand
@param string $amountB second operand
@return int 0 when both numbers are equal, 1 when $amountA is bigger than $amountB, -1 otherwise
Compare two numbers that are represented as a string