Package org.lwjgl.system
Class MathUtil
- java.lang.Object
-
- org.lwjgl.system.MathUtil
-
public final class MathUtil extends java.lang.ObjectMath utility class.Method names in this class are prefixed with
mathto avoid ambiguities when used with static imports.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static longmathDivideUnsigned(long dividend, long divisor)Returns the unsigned quotient of dividing the first argument by the second where each argument and the result is interpreted as an unsigned value.static booleanmathHasZeroByte(int value)static booleanmathHasZeroByte(long value)static booleanmathHasZeroShort(int value)static booleanmathHasZeroShort(long value)static booleanmathIsPoT(int value)Returns true if the specified integervalueis a power-of-two number.static longmathMultiplyHighS64(long x, long y)Returns as the most significant 64 bits of the 128-bit product of twoint64_tfactors.static longmathMultiplyHighU64(long x, long y)Returns as the most significant 64 bits of the 128-bit product of twouint64_tfactors.static longmathRemainderUnsigned(long dividend, long divisor)Returns the unsigned remainder from dividing the first argument by the second where each argument and the result is interpreted as an unsigned value.static intmathRoundPoT(int value)Rounds the specified integervalueup to the next power-of-two number.
-
-
-
Method Detail
-
mathIsPoT
public static boolean mathIsPoT(int value)
Returns true if the specified integervalueis 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 integervalueup to the next power-of-two number. The returned value will be equal tovalueif it already is a power-of-two number.- Parameters:
value- the value to round-up. Must be a number between1and1 << 30.- Returns:
- the power-of-two rounded value
-
mathHasZeroByte
public static boolean mathHasZeroByte(int value)
-
mathHasZeroByte
public static boolean mathHasZeroByte(long value)
-
mathHasZeroShort
public static boolean mathHasZeroShort(int value)
-
mathHasZeroShort
public static boolean mathHasZeroShort(long value)
-
mathMultiplyHighU64
public static long mathMultiplyHighU64(long x, long y)Returns as the most significant 64 bits of the 128-bit product of twouint64_tfactors.- Parameters:
x- the first valuey- the second value- Returns:
- the result
-
mathMultiplyHighS64
public static long mathMultiplyHighS64(long x, long y)Returns as the most significant 64 bits of the 128-bit product of twoint64_tfactors.- Parameters:
x- the first valuey- the second value- Returns:
- the result
-
mathDivideUnsigned
public static long mathDivideUnsigned(long dividend, long divisor)Returns the unsigned quotient of dividing the first argument by the second where each argument and the result is interpreted as an unsigned value.When either argument is negative (i.e. a
uint64_tvalue higher than0x8000_0000_0000_0000L), this method uses bit twiddling to implement the division. The JDK implementation usesBigIntegerfor this case, which has a negative impact on performance.- Parameters:
dividend- the value to be divideddivisor- the value doing the dividing- Returns:
- the unsigned quotient of the first argument divided by the second argument
-
mathRemainderUnsigned
public static long mathRemainderUnsigned(long dividend, long divisor)Returns the unsigned remainder from dividing the first argument by the second where each argument and the result is interpreted as an unsigned value.When either argument is negative (i.e. a
uint64_tvalue higher than0x8000_0000_0000_0000L), this method uses bit twiddling to implement the remainder. The JDK implementation usesBigIntegerfor this case, which has a negative impact on performance.- Parameters:
dividend- the value to be divideddivisor- the value doing the dividing- Returns:
- the unsigned remainder of the first argument divided by the second argument
-
-