Pow
@param DecimalValue $exponent
@return DecimalValue
168776
public function Pow( $exponent )
	{
		$exponent = $exponent instanceof DecimalValue ? $exponent : Convert::ToDecimal( $exponent );
		return new DecimalValue( bcpow( $this->getValue(), $exponent->getValue(), 21 ) );
	}
795709
public static <A extends Number & Comparable<?>> NumberExpression<Double> power(Expression<A> num, int exponent) {
        return Expressions.numberOperation(Double.class, Ops.MathOps.POWER, num, ConstantImpl.create(exponent));
    }
642889
public static BigDecimal decimalPow(BigDecimal number, BigDecimal power) {
        return new BigDecimal(Math.pow(number.doubleValue(), power.doubleValue()), MATH);
    }
501313
public static double exponent(Object left, Object right) throws PageException {
	return StrictMath.pow(Caster.toDoubleValue(left), Caster.toDoubleValue(right));
    }
1011187
protected function Mod( $val )
	{
		$val = $this->getOtherValue( $val );

		if ( is_infinite( $this->_value ) || is_nan( $this->_value ) || is_nan( $val ) || $val == 0 )
		{
			return new FloatProxy( NAN );
		}

		if ( is_infinite( $val ) )
		{
			return $this;
		}

		if ( is_infinite( $val ) )
		{
			return $val;
		}

		if ( $this->_value == 0 )
		{
			return $this;
		}

		$denominator = DecimalValue::FromFloat( $val );
		$result = DecimalValue::FromFloat( $this->_value )->Mod( $denominator );
		$result = $result->ToFloat( null );
		return new FloatProxy( $result );
	}
421639
public function modulus($modulus)
    {
        if (!is_numeric($modulus)) {
            throw new \InvalidArgumentException('Modulus must be numeric');
        }

        $amount = bcmod($this->amount, strval($modulus));

        return self::valueOf($amount, $this->currency);
    }
499235
public static function toCents($amount)
    {
        /*
         * There's probably a better way, but this is what i could come up with
         * to avoid rounding errors
         * todo: search for a better way
         */

        if (!is_float($amount)) {
            $type = gettype($amount);

            throw new \UnexpectedValueException("Needs a float! not $type");
        }

        //handle locales
        $locale = localeconv();

        $amount = str_replace($locale['mon_thousands_sep'], '', $amount);
        $amount = str_replace($locale['mon_decimal_point'], '.', $amount);
        $amount = str_replace($locale['decimal_point'], '.', $amount);

        $parts = explode('.', "$amount");

        // handle the case where $amount has a .0 fraction part
        if (count($parts) == 1) {
            $parts[] = '00';
        }

        list($whole, $fraction) = $parts;

        /*
         * since the documentation only mentions decimals with a precision of two
         * and doesn't specify any rounding method i'm truncating the number
         *
         * the str_pad is to handle the case where $amount is, for example, 6.9
         */
        $fraction = str_pad(substr($fraction, 0, 2), 2, '0');

        $whole = (int) $whole * 100;
        $fraction = (int) $fraction;

        return $whole + $fraction;
    }
416883
public function additiveInverse(): Decimal
    {
        if ($this->isZero()) {
            return $this;
        } elseif ($this->isNegative()) {
            $value = \substr($this->value, 1);
        } else { // if ($this->isPositive()) {
            $value = '-' . $this->value;
        }

        return new static($value, $this->scale);
    }
397845
static int requireValidExponent(final int exponent) {
        if (exponent < MIN_EXPONENT) {
            throw new IllegalArgumentException("exponent(" + exponent + ") < " + MIN_EXPONENT);
        }
        if (exponent > MAX_EXPONENT) {
            throw new IllegalArgumentException("exponent(" + exponent + ") > " + MAX_EXPONENT);
        }
        return exponent;
    }
499896
def remove_exponent(d):
    """"""
    return d.quantize(Decimal(1)) if d == d.to_integral() else d.normalize()
401854
def safe_pow(base, exp):
    """"""
    if exp > MAX_EXPONENT:
        raise RuntimeError("Invalid exponent, max exponent is {}".format(MAX_EXPONENT))
    return base ** exp
114419
@Override
	public RandomVariable pow(double exponent) {
		return apply(new DoubleUnaryOperator() {
			@Override
			public double applyAsDouble(double x) {
				return FastMath.pow(x, exponent);
			}
		});
	}
60031
public static function pow($base, $exponent)
    {
        if (!static::is($base) || !static::is($exponent)) {
            throw new \InvalidArgumentException("The \$base and \$exponent parameters must be of type int.");
        }

        return pow($base, $exponent);
    }
602936
public function arccot(int $scale = null): Decimal
    {
        $scale = ($scale === null) ? 32 : $scale;

        $piOverTwo = DecimalConstants::pi()->div(Decimal::fromInteger(2), $scale + 2);
        if ($this->round($scale)->isZero()) {
            return $piOverTwo->round($scale);
        }

        $piOverFour = DecimalConstants::pi()->div(Decimal::fromInteger(4), $scale + 2);
        if ($this->round($scale)->equals(DecimalConstants::one())) {
            return $piOverFour->round($scale);
        }
        if ($this->round($scale)->equals(DecimalConstants::negativeOne())) {
            return DecimalConstants::negativeOne()->mul($piOverFour, $scale + 2)->round($scale);
        }

        return $piOverTwo->sub(
            self::simplePowerSerie(
                $this,
                DecimalConstants::zero(),
                $scale + 2
            )
        )->round($scale);
    }
1226958
@NonNull
    public static Expression power(@NonNull Expression base, @NonNull Expression exponent) {
        if (base == null || exponent == null) {
            throw new IllegalArgumentException("base or exponent cannot be null.");
        }
        return new Expression.FunctionExpression("POWER()", Arrays.asList(base, exponent));
    }
1109487
public static function pow($z, $w) {
        // If exponent is an integer, compute the power using a square-and-multiply algorithm
        if (is_int($w)) return static::powi($z, $w);

        // Otherwise compute the principal branch: z^w = exp(wlog z)
        return static::exp(static::mul($w, static::log($z)));
    }
1145045
public function Mod( $denominator )
	{
		$denominator = $denominator instanceof DecimalValue ? $denominator : Convert::ToDecimal( $denominator );

		if ( $denominator->getIsZero() )
			throw XPath2Exception::withErrorCode( "FOAR0001", Resources::FOAR0001 );

		if ( $denominator->getIsNAN() )
			throw XPath2Exception::withErrorCode( "FOAR0002", Resources::FOAR0002 );

		if ( $this->getIsNAN() || $this->getIsInfinite() )
			throw XPath2Exception::withErrorCode( "FOAR0002", Resources::FOAR0002 );

		$power = 0;
		// bcmod does not handle decimals so if they exist the powers of the two numbers must be increased until there are no decimals
		if ( $this->getIsDecimal() )
		{
			$power = strlen( $this->getIntegerPart() );
		}

		if ( $denominator->getIsDecimal() )
		{
			$power = max( strlen( $denominator->getIntegerPart() ), $power );
		}

		$multiplier = new DecimalValue( 10 );
		$multiplier = $multiplier->Pow( new DecimalValue( $power ) );
		$numerator = $this->Mul( $multiplier );
		$denominator = $denominator->Mul( $multiplier );
		$mod = bcmod( $numerator->getIntegerPart(), $denominator->getIntegerPart() );

		// Now need to divide by the multiplier to restore the correct power
		$mod = new DecimalValue( $mod );
		$mod = $mod->Div( $multiplier );
		return $mod;
	}