Fix NextMultipleOf for int/long (#2289)

This commit is contained in:
wrexbe
2021-12-09 12:27:08 -08:00
committed by GitHub
parent 3332279e75
commit 9d1aff3a75

View File

@@ -172,7 +172,7 @@ namespace Robust.Shared.Maths
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static long NextMultipleOf(long value, long of)
{
return ((value - 1) | (of - 1)) + 1;
return ((value + of - 1) / of) * of;
}
/// <summary>
@@ -184,7 +184,7 @@ namespace Robust.Shared.Maths
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int NextMultipleOf(int value, int of)
{
return ((value - 1) | (of - 1)) + 1;
return ((value + of - 1) / of) * of;
}
#endregion