ExMath.cs 714 B

1234567891011121314151617181920212223242526272829303132333435
  1. namespace AtlasUtility
  2. {
  3. using UnityEngine;
  4. public static class ExMath
  5. {
  6. public static int PrevPOT(int value)
  7. {
  8. int closestPOT = Mathf.ClosestPowerOfTwo(value);
  9. if (closestPOT > value)
  10. {
  11. return closestPOT/2;
  12. }
  13. else
  14. {
  15. return closestPOT;
  16. }
  17. }
  18. public static int NextPOT(int value)
  19. {
  20. int closestPOT = Mathf.ClosestPowerOfTwo(value);
  21. if (closestPOT >= value)
  22. {
  23. return closestPOT;
  24. }
  25. else
  26. {
  27. return closestPOT*2;
  28. }
  29. }
  30. }
  31. }