Top Description Constructors Methods
org.lwjgl.system

public final Class MathUtil

extends Object
Class Inheritance
Imports
java.math.*

Math utility class.

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

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static long

Returns:

the unsigned quotient of the first argument divided by the second argument
mathDivideUnsigned
(long
the value to be divided
dividend
,
long
the value doing the dividing
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.

public static boolean
mathHasZeroByte(int value)

public static boolean
mathHasZeroByte(long value)

public static boolean
mathHasZeroShort(int value)

public static boolean
mathHasZeroShort(long value)

public static boolean

Returns:

true if the value if a power-of-two number.
mathIsPoT
(int
the value to test
value
)

Returns true if the specified integer value is a power-of-two number.

public static long

Returns:

the result
mathMultiplyHighS64
(long
the first value
x
,
long
the second value
y
)

Returns as a long the most significant 64 bits of the 128-bit product of two int64_t factors.

public static long

Returns:

the result
mathMultiplyHighU64
(long
the first value
x
,
long
the second value
y
)

Returns as a long the most significant 64 bits of the 128-bit product of two uint64_t factors.

public static long

Returns:

the unsigned remainder of the first argument divided by the second argument
mathRemainderUnsigned
(long
the value to be divided
dividend
,
long
the value doing the dividing
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.

public static int

Returns:

the power-of-two rounded value
mathRoundPoT
(int
the value to round-up. Must be a number between 1 and 1 << 30.
value
)

Rounds the specified integer value up to the next power-of-two number.

private static long
udivdi3(long u, long v)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

MathUtilback to summary
private MathUtil()

Method Detail

mathDivideUnsignedback to summary
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_t value higher than 0x8000_0000_0000_0000L), this method uses bit twiddling to implement the division. The JDK implementation uses BigInteger for this case, which has a negative impact on performance.

Parameters
dividend:long

the value to be divided

divisor:long

the value doing the dividing

Returns:long

the unsigned quotient of the first argument divided by the second argument

mathHasZeroByteback to summary
public static boolean mathHasZeroByte(int value)
mathHasZeroByteback to summary
public static boolean mathHasZeroByte(long value)
mathHasZeroShortback to summary
public static boolean mathHasZeroShort(int value)
mathHasZeroShortback to summary
public static boolean mathHasZeroShort(long value)
mathIsPoTback to summary
public static boolean mathIsPoT(int value)

Returns true if the specified integer value is a power-of-two number.

Parameters
value:int

the value to test

Returns:boolean

true if the value if a power-of-two number.

mathMultiplyHighS64back to summary
public static long mathMultiplyHighS64(long x, long y)

Returns as a long the most significant 64 bits of the 128-bit product of two int64_t factors.

Parameters
x:long

the first value

y:long

the second value

Returns:long

the result

mathMultiplyHighU64back to summary
public static long mathMultiplyHighU64(long x, long y)

Returns as a long the most significant 64 bits of the 128-bit product of two uint64_t factors.

Parameters
x:long

the first value

y:long

the second value

Returns:long

the result

mathRemainderUnsignedback to summary
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_t value higher than 0x8000_0000_0000_0000L), this method uses bit twiddling to implement the remainder. The JDK implementation uses BigInteger for this case, which has a negative impact on performance.

Parameters
dividend:long

the value to be divided

divisor:long

the value doing the dividing

Returns:long

the unsigned remainder of the first argument divided by the second argument

mathRoundPoTback to summary
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:int

the value to round-up. Must be a number between 1 and 1 << 30.

Returns:int

the power-of-two rounded value

udivdi3back to summary
private static long udivdi3(long u, long v)