Class IntUtils
Provides helper utility methods for integer mathematics, bit alignment, and prime numbers.
Only most common methods are purposely made as extension methods
Inheritance
System.Object
IntUtils
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Azos
Assembly: Azos.dll
Syntax
public static class IntUtils
Fields
PRIME_CAPACITIES
Declaration
public static readonly int[] PRIME_CAPACITIES
Field Value
| Type |
Description |
| System.Int32[] |
|
Methods
Align16(Int32)
Returns argument increased to the nearest number divisible by 16
Declaration
public static int Align16(int i)
Parameters
| Type |
Name |
Description |
| System.Int32 |
i |
|
Returns
| Type |
Description |
| System.Int32 |
|
Align16(Int64)
Returns argument increased to the nearest number divisible by 16
Declaration
public static long Align16(long i)
Parameters
| Type |
Name |
Description |
| System.Int64 |
i |
|
Returns
| Type |
Description |
| System.Int64 |
|
Align8(Int32)
Returns argument increased to the nearest number divisible by 8
Declaration
public static int Align8(int i)
Parameters
| Type |
Name |
Description |
| System.Int32 |
i |
|
Returns
| Type |
Description |
| System.Int32 |
|
Align8(Int64)
Returns argument increased to the nearest number divisible by 8
Declaration
public static long Align8(long i)
Parameters
| Type |
Name |
Description |
| System.Int64 |
i |
|
Returns
| Type |
Description |
| System.Int64 |
|
ChangeByRndPct(Int32, Single)
Changes the number by a random margin of up to the specified pct
Declaration
public static int ChangeByRndPct(this int value, float pct)
Parameters
| Type |
Name |
Description |
| System.Int32 |
value |
|
| System.Single |
pct |
|
Returns
| Type |
Description |
| System.Int32 |
|
ChangeByRndPct(Int64, Single)
Changes the number by a random margin of up to the specified pct
Declaration
public static long ChangeByRndPct(this long value, float pct)
Parameters
| Type |
Name |
Description |
| System.Int64 |
value |
|
| System.Single |
pct |
|
Returns
| Type |
Description |
| System.Int64 |
|
Gets adjacent prime number which is less than or equal to the specified number. Arguments less than 3 yield 2;
Declaration
public static int GetAdjacentPrimeNumberLessThanOrEqualTo(int number)
Parameters
| Type |
Name |
Description |
| System.Int32 |
number |
|
Returns
| Type |
Description |
| System.Int32 |
|
GetCapacityFactoredToPrime(Int32, Double)
Increases a capacity to a prime number by the factor. Both numbers must be positive
Declaration
public static int GetCapacityFactoredToPrime(int capacity, double factor)
Parameters
| Type |
Name |
Description |
| System.Int32 |
capacity |
|
| System.Double |
factor |
|
Returns
| Type |
Description |
| System.Int32 |
|
GetPrimeCapacityOfAtLeast(Int32)
Gets the capacity of at least or larger than the specified number. For numbers <= 16300007 the function uses lookup table for speed
Declaration
public static int GetPrimeCapacityOfAtLeast(int capacity)
Parameters
| Type |
Name |
Description |
| System.Int32 |
capacity |
|
Returns
| Type |
Description |
| System.Int32 |
|
IsPrime(Int32)
Tests if the number is prime
Declaration
public static bool IsPrime(int number)
Parameters
| Type |
Name |
Description |
| System.Int32 |
number |
|
Returns
| Type |
Description |
| System.Boolean |
|
Log(Int64, Int32)
Declaration
public static int Log(long n, int logBase = 2)
Parameters
| Type |
Name |
Description |
| System.Int64 |
n |
|
| System.Int32 |
logBase |
|
Returns
| Type |
Description |
| System.Int32 |
|
MinMax(Int32, Int32, Int32)
Declaration
public static int MinMax(int min, int value, int max)
Parameters
| Type |
Name |
Description |
| System.Int32 |
min |
|
| System.Int32 |
value |
|
| System.Int32 |
max |
|
Returns
| Type |
Description |
| System.Int32 |
|
Pow(Int64, Int32)
Declaration
public static long Pow(long n, int power)
Parameters
| Type |
Name |
Description |
| System.Int64 |
n |
|
| System.Int32 |
power |
|
Returns
| Type |
Description |
| System.Int64 |
|
UpperLog(Int64, Int32)
Declaration
public static int UpperLog(long n, int logBase = 2)
Parameters
| Type |
Name |
Description |
| System.Int64 |
n |
|
| System.Int32 |
logBase |
|
Returns
| Type |
Description |
| System.Int32 |
|
UpperPow(Int32, Int32)
Declaration
public static long UpperPow(int n, int powBase = 2)
Parameters
| Type |
Name |
Description |
| System.Int32 |
n |
|
| System.Int32 |
powBase |
|
Returns
| Type |
Description |
| System.Int64 |
|