IntegerMath.IsPowerOfTwo Method

Definition

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

Overload List

IsPowerOfTwo(BigInteger) Returns whether an integer is a power of two.
IsPowerOfTwo(Decimal) Returns whether an integer is a power of two.
IsPowerOfTwo(Int16) Returns whether an integer is a power of two.
IsPowerOfTwo(Int32) Returns whether an integer is a power of two.
IsPowerOfTwo(Int64) Returns whether a long integer is a power of two.
IsPowerOfTwo(UInt32) Returns whether an unsigned integer is a power of two.
IsPowerOfTwo(UInt64) Returns whether an unsigned long integer is a power of two.

IsPowerOfTwo(BigInteger)

Returns whether an integer is a power of two.
C#
public static bool IsPowerOfTwo(
	BigInteger n
)

Parameters

n  BigInteger
A BigInteger number.

Return Value

Boolean
true if the number is a power of two; false otherwise.

IsPowerOfTwo(Decimal)

Returns whether an integer is a power of two.
C#
public static bool IsPowerOfTwo(
	this decimal n
)

Parameters

n  Decimal
A Decimal number.

Return Value

Boolean
true if the number is a power of two; false otherwise.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Decimal. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

IsPowerOfTwo(Int16)

Returns whether an integer is a power of two.
C#
public static bool IsPowerOfTwo(
	this short n
)

Parameters

n  Int16
A 16-bit integer.

Return Value

Boolean
true if the number is a power of two; false otherwise.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Int16. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

IsPowerOfTwo(Int32)

Returns whether an integer is a power of two.
C#
public static bool IsPowerOfTwo(
	this int n
)

Parameters

n  Int32
A 32-bit integer.

Return Value

Boolean
true if the number is a power of two; false otherwise.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Int32. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

IsPowerOfTwo(Int64)

Returns whether a long integer is a power of two.
C#
public static bool IsPowerOfTwo(
	this long n
)

Parameters

n  Int64
A 64-bit integer.

Return Value

Boolean
true if the number is a power of two; false otherwise.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Int64. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

IsPowerOfTwo(UInt32)

Returns whether an unsigned integer is a power of two.
C#
public static bool IsPowerOfTwo(
	this uint n
)

Parameters

n  UInt32
A 32-bit unsigned integer.

Return Value

Boolean
true if the number is a power of two; false otherwise.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type UInt32. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

IsPowerOfTwo(UInt64)

Returns whether an unsigned long integer is a power of two.
C#
public static bool IsPowerOfTwo(
	this ulong n
)

Parameters

n  UInt64
A 64-bit unsigned integer.

Return Value

Boolean
true if the number is a power of two; false otherwise.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type UInt64. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

See Also