Version: Unity 6.7 Beta (6000.7)
LanguageEnglish
  • C#

CollectionHelper.Align

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public static int Align(int size, int alignmentPowerOfTwo);

Parameters

Parameter Description
size The size to align.
alignmentPowerOfTwo A non-zero, positive power of two.

Returns

int The smallest integer that is greater than or equal tosize and is a multiple of alignmentPowerOfTwo.

Description

Returns an allocation size in bytes that factors in alignment.

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

Declaration

public static long Align(long size, int alignmentPowerOfTwo);

Parameters

Parameter Description
size The size to align.
alignmentPowerOfTwo A non-zero, positive power of two.

Returns

long The smallest integer that is greater than or equal tosize and is a multiple of alignmentPowerOfTwo.

Description

Returns an allocation size in bytes that factors in alignment.

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

Declaration

public static ulong Align(ulong size, ulong alignmentPowerOfTwo);

Parameters

Parameter Description
size The size to align.
alignmentPowerOfTwo A non-zero, positive power of two.

Returns

ulong The smallest integer that is greater than or equal to size and is a multiple of alignmentPowerOfTwo.

Description

Returns an allocation size in bytes that factors in alignment.

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