Class NumericExtensions
- Namespace
- Garyon.Extensions
- Assembly
- Garyon.dll
Contains extension methods for numeric structures.
public static class NumericExtensions
- Inheritance
-
NumericExtensions
- Inherited Members
Methods
IsPowerOfTwo(byte)
Determines whether the value is a power of 2, using popcnt if supported, otherwise counting whether there only is 1 bit equal to 1.
public static bool IsPowerOfTwo(this byte value)
Parameters
valuebyteThe value to determine whether it is a power of 2.
Returns
IsPowerOfTwo(short)
Determines whether the value is a power of 2, using popcnt if supported, otherwise counting whether there only is 1 bit equal to 1. Negative values are ignored.
public static bool IsPowerOfTwo(this short value)
Parameters
valueshortThe value to determine whether it is a power of 2.
Returns
IsPowerOfTwo(int)
Determines whether the value is a power of 2, using popcnt if supported, otherwise counting whether there only is 1 bit equal to 1. Negative values are ignored.
public static bool IsPowerOfTwo(this int value)
Parameters
valueintThe value to determine whether it is a power of 2.
Returns
IsPowerOfTwo(long)
Determines whether the value is a power of 2, using popcnt if supported, otherwise counting whether there only is 1 bit equal to 1. Negative values are ignored.
public static bool IsPowerOfTwo(this long value)
Parameters
valuelongThe value to determine whether it is a power of 2.
Returns
IsPowerOfTwo(sbyte)
Determines whether the value is a power of 2, using popcnt if supported, otherwise counting whether there only is 1 bit equal to 1. Negative values are ignored.
public static bool IsPowerOfTwo(this sbyte value)
Parameters
valuesbyteThe value to determine whether it is a power of 2.
Returns
IsPowerOfTwo(ushort)
Determines whether the value is a power of 2, using popcnt if supported, otherwise counting whether there only is 1 bit equal to 1.
public static bool IsPowerOfTwo(this ushort value)
Parameters
valueushortThe value to determine whether it is a power of 2.
Returns
IsPowerOfTwo(uint)
Determines whether the value is a power of 2, using popcnt if supported, otherwise counting whether there only is 1 bit equal to 1.
public static bool IsPowerOfTwo(this uint value)
Parameters
valueuintThe value to determine whether it is a power of 2.
Returns
IsPowerOfTwo(ulong)
Determines whether the value is a power of 2, using popcnt if supported, otherwise counting whether there only is 1 bit equal to 1.
public static bool IsPowerOfTwo(this ulong value)
Parameters
valueulongThe value to determine whether it is a power of 2.
Returns
OneOrGreater(byte)
Determines whether the value is ≥1 and returns the value if ≥1, otherwise returns 1.
public static byte OneOrGreater(this byte value)
Parameters
valuebyteThe value to determine whether it is ≥1.
Returns
OneOrGreater(decimal)
Determines whether the value is ≥1 and returns the value if ≥1, otherwise returns 1.
public static decimal OneOrGreater(this decimal value)
Parameters
valuedecimalThe value to determine whether it is ≥1.
Returns
OneOrGreater(double)
Determines whether the value is ≥1 and returns the value if ≥1, otherwise returns 1.
public static double OneOrGreater(this double value)
Parameters
valuedoubleThe value to determine whether it is ≥1.
Returns
OneOrGreater(short)
Determines whether the value is ≥1 and returns the value if ≥1, otherwise returns 1.
public static short OneOrGreater(this short value)
Parameters
valueshortThe value to determine whether it is ≥1.
Returns
OneOrGreater(int)
Determines whether the value is ≥1 and returns the value if ≥1, otherwise returns 1.
public static int OneOrGreater(this int value)
Parameters
valueintThe value to determine whether it is ≥1.
Returns
OneOrGreater(long)
Determines whether the value is ≥1 and returns the value if ≥1, otherwise returns 1.
public static long OneOrGreater(this long value)
Parameters
valuelongThe value to determine whether it is ≥1.
Returns
OneOrGreater(sbyte)
Determines whether the value is ≥1 and returns the value if ≥1, otherwise returns 1.
public static sbyte OneOrGreater(this sbyte value)
Parameters
valuesbyteThe value to determine whether it is ≥1.
Returns
OneOrGreater(float)
Determines whether the value is ≥1 and returns the value if ≥1, otherwise returns 1.
public static float OneOrGreater(this float value)
Parameters
valuefloatThe value to determine whether it is ≥1.
Returns
OneOrGreater(ushort)
Determines whether the value is ≥1 and returns the value if ≥1, otherwise returns 1.
public static ushort OneOrGreater(this ushort value)
Parameters
valueushortThe value to determine whether it is ≥1.
Returns
OneOrGreater(uint)
Determines whether the value is ≥1 and returns the value if ≥1, otherwise returns 1.
public static uint OneOrGreater(this uint value)
Parameters
valueuintThe value to determine whether it is ≥1.
Returns
OneOrGreater(ulong)
Determines whether the value is ≥1 and returns the value if ≥1, otherwise returns 1.
public static ulong OneOrGreater(this ulong value)
Parameters
valueulongThe value to determine whether it is ≥1.
Returns
OneOrGreater<T>(T)
Determines whether the value is ≥1 and returns the value if ≥1, otherwise returns 1.
public static INumber<T> OneOrGreater<T>(this T value) where T : INumber<T>
Parameters
valueTThe value to determine whether it is ≥1.
Returns
- INumber<T>
Type Parameters
T
ZeroOrGreater(byte)
Determines whether the value is ≥0 and returns the value if ≥0, otherwise returns 0.
public static byte ZeroOrGreater(this byte value)
Parameters
valuebyteThe value to determine whether it is ≥0.
Returns
ZeroOrGreater(decimal)
Determines whether the value is ≥0 and returns the value if ≥0, otherwise returns 0.
public static decimal ZeroOrGreater(this decimal value)
Parameters
valuedecimalThe value to determine whether it is ≥0.
Returns
ZeroOrGreater(double)
Determines whether the value is ≥0 and returns the value if ≥0, otherwise returns 0.
public static double ZeroOrGreater(this double value)
Parameters
valuedoubleThe value to determine whether it is ≥0.
Returns
ZeroOrGreater(short)
Determines whether the value is ≥0 and returns the value if ≥0, otherwise returns 0.
public static short ZeroOrGreater(this short value)
Parameters
valueshortThe value to determine whether it is ≥0.
Returns
ZeroOrGreater(int)
Determines whether the value is ≥0 and returns the value if ≥0, otherwise returns 0.
public static int ZeroOrGreater(this int value)
Parameters
valueintThe value to determine whether it is ≥0.
Returns
ZeroOrGreater(long)
Determines whether the value is ≥0 and returns the value if ≥0, otherwise returns 0.
public static long ZeroOrGreater(this long value)
Parameters
valuelongThe value to determine whether it is ≥0.
Returns
ZeroOrGreater(sbyte)
Determines whether the value is ≥0 and returns the value if ≥0, otherwise returns 0.
public static sbyte ZeroOrGreater(this sbyte value)
Parameters
valuesbyteThe value to determine whether it is ≥0.
Returns
ZeroOrGreater(float)
Determines whether the value is ≥0 and returns the value if ≥0, otherwise returns 0.
public static float ZeroOrGreater(this float value)
Parameters
valuefloatThe value to determine whether it is ≥0.
Returns
ZeroOrGreater(ushort)
Determines whether the value is ≥0 and returns the value if ≥0, otherwise returns 0.
public static ushort ZeroOrGreater(this ushort value)
Parameters
valueushortThe value to determine whether it is ≥0.
Returns
ZeroOrGreater(uint)
Determines whether the value is ≥0 and returns the value if ≥0, otherwise returns 0.
public static uint ZeroOrGreater(this uint value)
Parameters
valueuintThe value to determine whether it is ≥0.
Returns
ZeroOrGreater(ulong)
Determines whether the value is ≥0 and returns the value if ≥0, otherwise returns 0.
public static ulong ZeroOrGreater(this ulong value)
Parameters
valueulongThe value to determine whether it is ≥0.
Returns
ZeroOrGreater<T>(T)
Determines whether the value is ≥0 and returns the value if ≥0, otherwise returns 0.
public static INumber<T> ZeroOrGreater<T>(this T value) where T : INumber<T>
Parameters
valueTThe value to determine whether it is ≥0.
Returns
- INumber<T>
Type Parameters
T