Return percent x of y;

@param $big
@param $small
@param int   $defaultOnZero

@return string
326338
public static function percentOf($big, $small, $defaultOnZero = 0)
    {
        $result = $big > 0.01 ? (($small*100)/$big) : $defaultOnZero;
        return self::nFloat($result);
    }
1290384
public function getVariable($key, $default = null, $deep = false)
    {
        return $this->variables->get($key, $default, $deep);
    }
523261
public static function zero() : BigRational
    {
        static $zero;

        if ($zero === null) {
            $zero = new BigRational(BigInteger::zero(), BigInteger::one(), false);
        }

        return $zero;
    }
814931
public static boolean lessThan(Time small, Time big) {
        return compare(small, big, CompareWay.LT);
    }
1219640
public function protectedReduce($x, $n, $mode)
    {
        switch ($mode) {
            case MATH_BIGINTEGER_MONTGOMERY:
                return $this->protectedMontgomery($x, $n);
            case MATH_BIGINTEGER_BARRETT:
                return $this->protectedBarrett($x, $n);
            case MATH_BIGINTEGER_POWEROF2:
                $lhs = new BigInteger();
                $lhs->value = $x;
                $rhs = new BigInteger();
                $rhs->value = $n;
                return $x->protectedMod2($n);
            case MATH_BIGINTEGER_CLASSIC:
                $lhs = new BigInteger();
                $lhs->value = $x;
                $rhs = new BigInteger();
                $rhs->value = $n;
                list ($temp) = $lhs->divide($rhs);
                return $temp->value;
            case MATH_BIGINTEGER_NONE:
                return $x;
            default:
                // an invalid $mode was provided
        }
    }
801058
private function getMaxIdx($parentId = 0, $lessThen = false)
    {
        $query = call_user_func("$this->ownerClassName::find")
            ->select("MAX($this->sortField)");
        if ( $lessThen !== false ) {
            $query->where([ '<', $this->sortField, $lessThen ]);
        }
        if ( $this->parentIdField ) {
            $query->andWhere([ $this->parentIdField => $parentId ]);
        }
        $result = $query->scalar();
        if ( $result === null ) {
            $result = floor($lessThen / 2);
        }
        return (int)$result;
    }
473909
private int compareMagnitude(BigDecimal val) {
        // Match scales, avoid unnecessary inflation
        long ys = val.intCompact;
        long xs = this.intCompact;
        if (xs == 0)
            return (ys == 0) ? 0 : -1;
        if (ys == 0)
            return 1;

        long sdiff = (long)this.scale - val.scale;
        if (sdiff != 0) {
            // Avoid matching scales if the (adjusted) exponents differ
            long xae = (long)this.precision() - this.scale;   // [-1]
            long yae = (long)val.precision() - val.scale;     // [-1]
            if (xae < yae)
                return -1;
            if (xae > yae)
                return 1;
            BigInteger rb = null;
            if (sdiff < 0) {
                // The cases sdiff <= Integer.MIN_VALUE intentionally fall through.
                if ( sdiff > Integer.MIN_VALUE &&
                      (xs == INFLATED ||
                      (xs = longMultiplyPowerTen(xs, (int)-sdiff)) == INFLATED) &&
                     ys == INFLATED) {
                    rb = bigMultiplyPowerTen((int)-sdiff);
                    return rb.compareMagnitude(val.intVal);
                }
            } else { // sdiff > 0
                // The cases sdiff > Integer.MAX_VALUE intentionally fall through.
                if ( sdiff <= Integer.MAX_VALUE &&
                      (ys == INFLATED ||
                      (ys = longMultiplyPowerTen(ys, (int)sdiff)) == INFLATED) &&
                     xs == INFLATED) {
                    rb = val.bigMultiplyPowerTen((int)sdiff);
                    return this.intVal.compareMagnitude(rb);
                }
            }
        }
        if (xs != INFLATED)
            return (ys != INFLATED) ? longCompareMagnitude(xs, ys) : -1;
        else if (ys != INFLATED)
            return 1;
        else
            return this.intVal.compareMagnitude(val.intVal);
    }
540911
def greater(x, y):
    
    x = BigFloat._implicit_convert(x)
    y = BigFloat._implicit_convert(y)
    return mpfr.mpfr_greater_p(x, y)
1150198
function bitwise_or($x)
    {
        switch (MATH_BIGINTEGER_MODE) {
            case self::MODE_GMP:
                $temp = new static();
                $temp->value = gmp_or($this->value, $x->value);

                return $this->_normalize($temp);
            case self::MODE_BCMATH:
                $left = $this->toBytes();
                $right = $x->toBytes();

                $length = max(strlen($left), strlen($right));

                $left = str_pad($left, $length, chr(0), STR_PAD_LEFT);
                $right = str_pad($right, $length, chr(0), STR_PAD_LEFT);

                return $this->_normalize(new static($left | $right, 256));
        }

        $length = max(count($this->value), count($x->value));
        $result = $this->copy();
        $result->value = array_pad($result->value, $length, 0);
        $x->value = array_pad($x->value, $length, 0);

        for ($i = 0; $i < $length; ++$i) {
            $result->value[$i]|= $x->value[$i];
        }

        return $this->_normalize($result);
    }
188508
public static boolean sameZero(Object x, Object y) {
        if (!typeof(x).equals(typeof(y))) {
            return false;
        }
        if (x instanceof Number) {
            if (isNaN(x) && isNaN(y)) {
                return true;
            }
            final double dx = ((Number)x).doubleValue();
            if (y instanceof Number) {
                final double dy = ((Number)y).doubleValue();
                if (((dx == negativeZero) && (dy == 0.0)) ||
                    ((dx == 0.0) && dy == negativeZero)) {
                        return true;
                }
            }
            return eqNumber(dx, y);
        }
        return eq(x, y);
    }
810302
private static int compareMagnitudeNormalized(long xs, int xscale, BigInteger ys, int yscale) {
        // assert "ys can't be represented as long"
        if (xs == 0)
            return -1;
        int sdiff = xscale - yscale;
        if (sdiff < 0) {
            if (longMultiplyPowerTen(xs, -sdiff) == INFLATED ) {
                return bigMultiplyPowerTen(xs, -sdiff).compareMagnitude(ys);
            }
        }
        return -1;
    }
581911
public static function ten() : BigRational
    {
        static $ten;

        if ($ten === null) {
            $ten = new BigRational(BigInteger::ten(), BigInteger::one(), false);
        }

        return $ten;
    }
234413
public static function percentageOf($n1, $n2, $round = false)
    {
        $decimal    = self::div($n1, $n2);
        $percentage = self::mul($decimal, 100);

        return $round ? self::round($percentage) : (float)$percentage;
    }
379298
public function getAmount($currency) : BigRational
    {
        $currencyCode = (string) $currency;

        return isset($this->amounts[$currencyCode])
            ? $this->amounts[$currencyCode]
            : BigRational::zero();
    }
1207375
private function getUnscaledValueWithLeadingZeros() : string
    {
        $value = $this->value;
        $targetLength = $this->scale + 1;
        $negative = ($value[0] === '-');
        $length = \strlen($value);

        if ($negative) {
            $length--;
        }

        if ($length >= $targetLength) {
            return $this->value;
        }

        if ($negative) {
            $value = \substr($value, 1);
        }

        $value = \str_pad($value, $targetLength, '0', STR_PAD_LEFT);

        if ($negative) {
            $value = '-' . $value;
        }

        return $value;
    }
1104209
function bitwise_and($x)
    {
        switch (MATH_BIGINTEGER_MODE) {
            case MATH_BIGINTEGER_MODE_GMP:
                $temp = new Math_BigInteger();
                $temp->value = gmp_and($this->value, $x->value);

                return $this->_normalize($temp);
            case MATH_BIGINTEGER_MODE_BCMATH:
                $left = $this->toBytes();
                $right = $x->toBytes();

                $length = max(strlen($left), strlen($right));

                $left = str_pad($left, $length, chr(0), STR_PAD_LEFT);
                $right = str_pad($right, $length, chr(0), STR_PAD_LEFT);

                return $this->_normalize(new Math_BigInteger($left & $right, 256));
        }

        $result = $this->copy();

        $length = min(count($x->value), count($this->value));

        $result->value = array_slice($result->value, 0, $length);

        for ($i = 0; $i < $length; ++$i) {
            $result->value[$i]&= $x->value[$i];
        }

        return $this->_normalize($result);
    }
333085
private static final long10 mul_small(long10 xy, long10 x, long y) {
		long t;
		t = (x._8*y);
		xy._8 = (t & ((1 << 26) - 1));
		t = (t >> 26) + (x._9*y);
		xy._9 = (t & ((1 << 25) - 1));
		t = 19 * (t >> 25) + (x._0*y);
		xy._0 = (t & ((1 << 26) - 1));
		t = (t >> 26) + (x._1*y);
		xy._1 = (t & ((1 << 25) - 1));
		t = (t >> 25) + (x._2*y);
		xy._2 = (t & ((1 << 26) - 1));
		t = (t >> 26) + (x._3*y);
		xy._3 = (t & ((1 << 25) - 1));
		t = (t >> 25) + (x._4*y);
		xy._4 = (t & ((1 << 26) - 1));
		t = (t >> 26) + (x._5*y);
		xy._5 = (t & ((1 << 25) - 1));
		t = (t >> 25) + (x._6*y);
		xy._6 = (t & ((1 << 26) - 1));
		t = (t >> 26) + (x._7*y);
		xy._7 = (t & ((1 << 25) - 1));
		t = (t >> 25) + xy._8;
		xy._8 = (t & ((1 << 26) - 1));
		xy._9 += (t >> 26);
		return xy;
	}