Package org.ojalgo.function.special
Class PowerOf2
java.lang.Object
org.ojalgo.function.special.PowerOf2
- Direct Known Subclasses:
PowerOf2.IntPower
,PowerOf2.LongPower
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
static final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal int
private static final int[]
private static double
private static final long[]
static final int
static final long
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic long
adjustDown
(double value) static int
adjustDown
(float value) static long
adjustUp
(double value) static int
adjustUp
(float value) static int
exponent
(double value) 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.static int
find
(long value) static PowerOf2.IntPower
getIntPower
(int exponent) static PowerOf2.LongPower
getLongPower
(int exponent) static boolean
isPowerOf2
(int value) static boolean
isPowerOf2
(long value) static int
largestNotGreaterThan
(int value) static long
largestNotGreaterThan
(long value) static int
powerOf2Larger
(int value) static int
powerOf2Larger
(long value) static int
powerOf2Smaller
(int value) static int
powerOf2Smaller
(long value) static int
powerOfInt2
(int exponent) static long
powerOfLong2
(int exponent) static int
smallestNotLessThan
(int value) static long
smallestNotLessThan
(long value)
-
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
-
getLongPower
-
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)
-