Class MathUtil



  • public final class MathUtil
    extends java.lang.Object
    Math utility class.

    Method names in this class are prefixed with math to avoid ambiguities when used with static imports.

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static boolean mathIsPoT(int value)
      Returns true if the specified integer value is a power-of-two number.
      static int mathRoundPoT(int value)
      Rounds the specified integer value up to the next power-of-two number.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • mathIsPoT

        public static boolean mathIsPoT(int value)
        Returns true if the specified integer value is a power-of-two number.
        Parameters:
        value - the value to test
        Returns:
        true if the value if a power-of-two number.
      • mathRoundPoT

        public static int mathRoundPoT(int value)
        Rounds the specified integer value up to the next power-of-two number. The returned value will be equal to value if it already is a power-of-two number.
        Parameters:
        value - the value to round-up. Must be a number between 1 and 1 << 30.
        Returns:
        the power-of-two rounded value