Class PowerOf2

java.lang.Object
org.ojalgo.function.special.PowerOf2
Direct Known Subclasses:
PowerOf2.IntPower, PowerOf2.LongPower

public abstract class PowerOf2 extends Object
  • Field Details

    • MAX_INT

      public static final int MAX_INT
    • MAX_LONG

      public static final long MAX_LONG
    • INT_POWERS

      private static final int[] INT_POWERS
    • LN2

      private static double LN2
    • LONG_POWERS

      private static final long[] LONG_POWERS
    • exponent

      public final int exponent
  • Constructor Details

    • PowerOf2

      PowerOf2(int exp)
  • Method Details

    • adjustDown

      public static long adjustDown(double value)
      See Also:
    • adjustDown

      public static int adjustDown(float value)
      See Also:
    • adjustUp

      public static long adjustUp(double value)
      See Also:
    • adjustUp

      public static int adjustUp(float value)
      See Also:
    • exponent

      public static int exponent(double value)
    • find

      public static int find(int value)
      If the input value is a power of 2 then the exponent is returned, if not a negative number is returned.
    • find

      public static int find(long value)
      See Also:
    • getIntPower

      public static PowerOf2.IntPower getIntPower(int exponent)
    • getLongPower

      public static PowerOf2.LongPower getLongPower(int exponent)
    • isPowerOf2

      public static boolean isPowerOf2(int value)
    • isPowerOf2

      public static boolean isPowerOf2(long value)
    • largestNotGreaterThan

      public static int largestNotGreaterThan(int value)
      Returns:
      The largest power of 2 that is less than or equal to the input (not greater than)
    • largestNotGreaterThan

      public static long largestNotGreaterThan(long value)
      Returns:
      The largest power of 2 that is less than or equal to the input (not greater than)
    • powerOf2Larger

      public static int powerOf2Larger(int value)
      Returns:
      The smallest integer exponent so that 2^exp >= value.
    • powerOf2Larger

      public static int powerOf2Larger(long value)
      Returns:
      The smallest integer exponent so that 2^exp >= value.
    • powerOf2Smaller

      public static int powerOf2Smaller(int value)
      Returns:
      The largest integer exponent so that 2^exp <= value.
    • powerOf2Smaller

      public static int powerOf2Smaller(long value)
      Returns:
      The largest integer exponent so that 2^exp <= value.
    • powerOfInt2

      public static int powerOfInt2(int exponent)
    • powerOfLong2

      public static long powerOfLong2(int exponent)
    • smallestNotLessThan

      public static int smallestNotLessThan(int value)
      Returns:
      The smallest power of 2 that is greater than or equal to the input (not less than)
    • smallestNotLessThan

      public static long smallestNotLessThan(long value)
      Returns:
      The smallest power of 2 that is greater than or equal to the input (not less than)