1234567891011121314151617181920212223242526272829303132333435 |
- namespace AtlasUtility
- {
- using UnityEngine;
- public static class ExMath
- {
- public static int PrevPOT(int value)
- {
- int closestPOT = Mathf.ClosestPowerOfTwo(value);
- if (closestPOT > value)
- {
- return closestPOT/2;
- }
- else
- {
- return closestPOT;
- }
- }
- public static int NextPOT(int value)
- {
- int closestPOT = Mathf.ClosestPowerOfTwo(value);
- if (closestPOT >= value)
- {
- return closestPOT;
- }
- else
- {
- return closestPOT*2;
- }
- }
- }
- }
|