Files
Debug_pro 8d81324fd9 be
2026-03-03 04:00:06 +03:00

26 lines
542 B
C#

namespace Prac7Meow
{
internal class Utils
{
public static int NearPow(int n)
{
if (n == 0) return 0;
if (n <= 2) return 2;
uint val = (uint)n;
val--;
val |= val >> 1;
val |= val >> 2;
val |= val >> 4;
val |= val >> 8;
val |= val >> 16;
val++;
if (val == 0) throw new OverflowException("Requested capacity is too large for int.");
return (int)val;
}
}
}