- java.lang.Object
-
- org.ojalgo.function.special.PowerOf2
-
- Direct Known Subclasses:
PowerOf2.IntPower,PowerOf2.LongPower
public abstract class PowerOf2 extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPowerOf2.IntPowerstatic classPowerOf2.LongPower
-
Field Summary
Fields Modifier and Type Field Description intexponentprivate static int[]INT_POWERSprivate static doubleLN2private static long[]LONG_POWERSstatic intMAX_INTstatic longMAX_LONG
-
Constructor Summary
Constructors Constructor Description PowerOf2(int exp)
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static longadjustDown(double value)static intadjustDown(float value)static longadjustUp(double value)static intadjustUp(float value)static intexponent(double value)static intfind(int value)If the input value is a power of 2 then the exponent is returned, if not a negative number is returned.static intfind(long value)static PowerOf2.IntPowergetIntPower(int exponent)static PowerOf2.LongPowergetLongPower(int exponent)static booleanisPowerOf2(int value)static booleanisPowerOf2(long value)static intlargestNotGreaterThan(int value)static longlargestNotGreaterThan(long value)static intpowerOf2Larger(int value)static intpowerOf2Larger(long value)static intpowerOf2Smaller(int value)static intpowerOf2Smaller(long value)static intpowerOfInt2(int exponent)static longpowerOfLong2(int exponent)static intsmallestNotLessThan(int value)static longsmallestNotLessThan(long value)
-
-
-
Method Detail
-
adjustDown
public static long adjustDown(double value)
- See Also:
largestNotGreaterThan(long)
-
adjustDown
public static int adjustDown(float value)
- See Also:
largestNotGreaterThan(int)
-
adjustUp
public static long adjustUp(double value)
- See Also:
smallestNotLessThan(long)
-
adjustUp
public static int adjustUp(float value)
- See Also:
smallestNotLessThan(int)
-
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:
find(int)
-
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)
-
-