# Align

> Returns an allocation size in bytes that factors in alignment.

## Definition

* **Type:** Method
* **Namespace:** [Unity.Collections](/engine/6000.7/script-reference/unity/collections.md)
* **Assembly:** UnityEngine.ManagedKernelModule

## Align(int, int)

Returns an allocation size in bytes that factors in alignment.

```csharp
public static int Align(int size, int alignmentPowerOfTwo)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The size to align.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): A non-zero, positive power of two.

### Returns

| Type                                                       | Description                                                                                             |
| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The smallest integer that is greater than or equal to`size` and is a multiple of `alignmentPowerOfTwo`. |

### Examples

```csharp
// 55 aligned to 16 is 64.
int size = CollectionHelper.Align(55, 16);
```

## Align(long, int)

Returns an allocation size in bytes that factors in alignment.

```csharp
public static long Align(long size, int alignmentPowerOfTwo)
```

### Parameters

**** (\[long]\(https\://learn.microsoft.com/dotnet/api/system.int64)): The size to align.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): A non-zero, positive power of two.

### Returns

| Type                                                        | Description                                                                                             |
| ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
| [long](https://learn.microsoft.com/dotnet/api/system.int64) | The smallest integer that is greater than or equal to`size` and is a multiple of `alignmentPowerOfTwo`. |

### Examples

```csharp
// 55 aligned to 16 is 64.
long size = CollectionHelper.Align(55, 16);
```

## Align(ulong, ulong)

Returns an allocation size in bytes that factors in alignment.

```csharp
public static ulong Align(ulong size, ulong alignmentPowerOfTwo)
```

### Parameters

**** (\[ulong]\(https\://learn.microsoft.com/dotnet/api/system.uint64)): The size to align.**** (\[ulong]\(https\://learn.microsoft.com/dotnet/api/system.uint64)): A non-zero, positive power of two.

### Returns

| Type                                                          | Description                                                                                              |
| ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| [ulong](https://learn.microsoft.com/dotnet/api/system.uint64) | The smallest integer that is greater than or equal to `size` and is a multiple of `alignmentPowerOfTwo`. |

### Examples

```csharp
// 55 aligned to 16 is 64.
ulong size = CollectionHelper.Align(55, 16);
```
