DecimalMath.Pow Method

Definition

Namespace: Numerics.NET
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 9.0.2

Overload List

Pow(Decimal, Decimal) Returns a specified number raised to the specified power.
Pow(Decimal, Int32) Returns a number raised to an integer power.

Pow(Decimal, Decimal)

Returns a specified number raised to the specified power.
C#
public static decimal Pow(
	decimal value,
	decimal exponent
)

Parameters

value  Decimal
A decimal value to be raised to a power.
exponent  Decimal
A decimal value that specifies a power.

Return Value

Decimal
The number value raised to the power exponent.

Exceptions

DivideByZeroException

value is zero and exponent is less than zero.

OverflowException

The result is too large to be represented by a decimal value.

ArgumentOutOfRangeException

Both value and exponent are zero

-or-

value is negative and exponent is not an integer.

Pow(Decimal, Int32)

Returns a number raised to an integer power.
C#
public static decimal Pow(
	decimal value,
	int exponent
)

Parameters

value  Decimal
A real number.
exponent  Int32
An integer exponent.

Return Value

Decimal
The real number raised to the specified exponent.

Remarks

Raising a number to an integer power is orders of magnitude faster than raising a number to a real power. If you know the exponent is an integer, use this method instead of the Pow(Double, Double) method of Math.

Exceptions

DivideByZeroException

value is zero and exponent is less than zero.

OverflowException

The result is too large to be represented by a decimal value.

See Also