Method Align
Align(int, int)
Returns an allocation size in bytes that factors in alignment.
Declaration
public static int Align(int size, int alignmentPowerOfTwo)
Parameters
| Type | Name | Description |
|---|---|---|
| int | size | The size to align. |
| int | alignmentPowerOfTwo | A non-zero, positive power of two. |
Returns
| Type | Description |
|---|---|
| int | The smallest integer that is greater than or equal to |
Examples
// 55 aligned to 16 is 64.
int size = CollectionHelper.Align(55, 16);
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown if |
Align(ulong, ulong)
Returns an allocation size in bytes that factors in alignment.
Declaration
public static ulong Align(ulong size, ulong alignmentPowerOfTwo)
Parameters
| Type | Name | Description |
|---|---|---|
| ulong | size | The size to align. |
| ulong | alignmentPowerOfTwo | A non-zero, positive power of two. |
Returns
| Type | Description |
|---|---|
| ulong | The smallest integer that is greater than or equal to |
Examples
// 55 aligned to 16 is 64.
ulong size = CollectionHelper.Align(55, 16);
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown if |