Class VectorMath
VectorMath contains methods for performing
scalar numeric operations in support of vector numeric operations.- Since:
- 24
-
Method Summary
Modifier and TypeMethodDescriptionstatic byteaddSaturating(byte a, byte b) Adds twobytevalues using saturation arithmetic.static intaddSaturating(int a, int b) Adds twointvalues using saturation arithmetic.static longaddSaturating(long a, long b) Adds twolongvalues using saturation arithmetic.static shortaddSaturating(short a, short b) Adds twoshortvalues using saturation arithmetic.static byteaddSaturatingUnsigned(byte a, byte b) Adds twobytevalues using saturation arithmetic and numerically treating the values as unsigned.static intaddSaturatingUnsigned(int a, int b) Adds twointvalues using saturation arithmetic and numerically treating the values as unsigned.static longaddSaturatingUnsigned(long a, long b) Adds twolongvalues using saturation arithmetic and numerically treating the values as unsigned.static shortaddSaturatingUnsigned(short a, short b) Adds twoshortvalues using saturation arithmetic and numerically treating the values as unsigned.static bytemaxUnsigned(byte a, byte b) Returns the greater of twobytevalues numerically treating the values as unsigned.static intmaxUnsigned(int a, int b) Returns the greater of twointvalues numerically treating the values as unsigned.static longmaxUnsigned(long a, long b) Returns the greater of twolongvalues numerically treating the values as unsigned.static shortmaxUnsigned(short a, short b) Returns the greater of twoshortvalues numerically treating the values as unsigned.static byteminUnsigned(byte a, byte b) Returns the smaller of twobytevalues numerically treating the values as unsigned.static intminUnsigned(int a, int b) Returns the smaller of twointvalues numerically treating the values as unsigned.static longminUnsigned(long a, long b) Returns the smaller of twolongvalues numerically treating the values as unsigned.static shortminUnsigned(short a, short b) Returns the smaller of twoshortvalues numerically treating the values as unsigned.static bytesubSaturating(byte a, byte b) Subtracts twobytevalues using saturation arithmetic.static intsubSaturating(int a, int b) Subtracts twointvalues using saturation arithmetic.static longsubSaturating(long a, long b) Subtracts twolongvalues using saturation arithmetic.static shortsubSaturating(short a, short b) Subtracts twoshortvalues using saturation arithmetic.static bytesubSaturatingUnsigned(byte a, byte b) Subtracts twobytevalues using saturation arithmetic and numerically treating the values as unsigned.static intsubSaturatingUnsigned(int a, int b) Subtracts twointvalues using saturation arithmetic and numerically treating the values as unsigned.static longsubSaturatingUnsigned(long a, long b) Subtracts twolongvalues using saturation arithmetic and numerically treating the values as unsigned.static shortsubSaturatingUnsigned(short a, short b) Subtracts twoshortvalues using saturation arithmetic and numerically treating the values as unsigned.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.booleanCompares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.May cause performance issues, deadlocks and hangs.getClass()Answers the unique instance of java.lang.Class which represents the class of the receiver.inthashCode()Answers an integer hash code for the receiver.final voidnotify()Causes one thread which iswaiting on the receiver to be made ready to run.final voidCauses all threads which arewaiting on the receiver to be made ready to run.toString()Answers a string containing a concise, human-readable description of the receiver.final voidwait()Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated bynotifyornotifyAll).final voidwait(long time) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.final voidwait(long time, int frac) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.
-
Method Details
-
minUnsigned
public static long minUnsigned(long a, long b) Returns the smaller of twolongvalues numerically treating the values as unsigned. That is, the result is the operand closer to the value of the expression0L. If the operands have the same value, the result is that same value.- Parameters:
a- the first operand.b- the second operand.- Returns:
- the smaller of
aandb. - See Also:
-
maxUnsigned
public static long maxUnsigned(long a, long b) Returns the greater of twolongvalues numerically treating the values as unsigned. That is, the result is the operand closer to the value of the expression0xFFFFFFFF_FFFFFFFFLnumerically treating it as unsigned. If the operands have the same value, the result is that same value.- Parameters:
a- the first operand.b- the second operand.- Returns:
- the larger of
aandb. - See Also:
-
addSaturating
public static long addSaturating(long a, long b) Adds twolongvalues using saturation arithmetic. The lower and upper (inclusive) bounds areLong.MIN_VALUEandLong.MAX_VALUE, respectively.If the result of the addition would otherwise overflow from a positive value to a negative value then the result is clamped to the upper bound
Long.MAX_VALUE. If the result of the addition would otherwise underflow from a negative value to a positive value then the result is clamped to lower boundLong.MIN_VALUE.- Parameters:
a- the first operand.b- the second operand.- Returns:
- the saturating addition of the operands.
- See Also:
-
subSaturating
public static long subSaturating(long a, long b) Subtracts twolongvalues using saturation arithmetic. The lower and upper (inclusive) bounds areLong.MIN_VALUEandLong.MAX_VALUE, respectively.If the result of the subtraction would otherwise overflow from a positive value to a negative value then the result is clamped to the upper bound
Long.MAX_VALUE. If the result of the subtraction would otherwise underflow from a negative value to a positive value then the result is clamped to lower boundLong.MIN_VALUE.- Parameters:
a- the first operand.b- the second operand.- Returns:
- the saturating difference of the operands.
- See Also:
-
addSaturatingUnsigned
public static long addSaturatingUnsigned(long a, long b) Adds twolongvalues using saturation arithmetic and numerically treating the values as unsigned. The lower and upper (inclusive) bounds are0Land0xFFFFFFFF_FFFFFFFFL, respectively, numerically treating them as unsigned.If the result of the unsigned addition would otherwise overflow from the greater of the two operands to a lesser value then the result is clamped to the upper bound
0xFFFFFFFF_FFFFFFFFL.- Parameters:
a- the first operand.b- the second operand.- Returns:
- the saturating addition of the operands.
- See Also:
-
subSaturatingUnsigned
public static long subSaturatingUnsigned(long a, long b) Subtracts twolongvalues using saturation arithmetic and numerically treating the values as unsigned. The lower and upper (inclusive) bounds are0Land0xFFFFFFFF_FFFFFFFFL, respectively, numerically treating them as unsigned.If the result of the unsigned subtraction would otherwise underflow from the lesser of the two operands to a greater value then the result is clamped to the lower bound
0L.- Parameters:
a- the first operand.b- the second operand.- Returns:
- the saturating difference of the operands.
- See Also:
-
minUnsigned
public static int minUnsigned(int a, int b) Returns the smaller of twointvalues numerically treating the values as unsigned. That is, the result is the operand closer to the value of the expression0. If the operands have the same value, the result is that same value.- Parameters:
a- the first operand.b- the second operand.- Returns:
- the smaller of
aandb. - See Also:
-
maxUnsigned
public static int maxUnsigned(int a, int b) Returns the greater of twointvalues numerically treating the values as unsigned. That is, the result is the operand closer to the value of the expression0xFFFFFFFFnumerically treating it as unsigned. If the operands have the same value, the result is that same value.- Parameters:
a- the first operand.b- the second operand.- Returns:
- the larger of
aandb. - See Also:
-
addSaturating
public static int addSaturating(int a, int b) Adds twointvalues using saturation arithmetic. The lower and upper (inclusive) bounds areInteger.MIN_VALUEandInteger.MAX_VALUE, respectively.If the result of the addition would otherwise overflow from a positive value to a negative value then the result is clamped to the upper bound
Integer.MAX_VALUE. If the result of the addition would otherwise underflow from a negative value to a positive value then the result is clamped to lower boundInteger.MIN_VALUE.- Parameters:
a- the first operand.b- the second operand.- Returns:
- the saturating addition of the operands.
- See Also:
-
subSaturating
public static int subSaturating(int a, int b) Subtracts twointvalues using saturation arithmetic. The lower and upper (inclusive) bounds areInteger.MIN_VALUEandInteger.MAX_VALUE, respectively.If the result of the subtraction would otherwise overflow from a positive value to a negative value then the result is clamped to the upper bound
Integer.MAX_VALUE. If the result of the subtraction would otherwise underflow from a negative value to a positive value then the result is clamped to lower boundInteger.MIN_VALUE.- Parameters:
a- the first operand.b- the second operand.- Returns:
- the saturating difference of the operands.
- See Also:
-
addSaturatingUnsigned
public static int addSaturatingUnsigned(int a, int b) Adds twointvalues using saturation arithmetic and numerically treating the values as unsigned. The lower and upper (inclusive) bounds are0and0xFFFFFFFF, respectively, numerically treating them as unsigned.If the result of the unsigned addition would otherwise overflow from the greater of the two operands to a lesser value then the result is clamped to the upper bound
0xFFFFFFFF.- Parameters:
a- the first operand.b- the second operand.- Returns:
- the saturating addition of the operands.
- See Also:
-
subSaturatingUnsigned
public static int subSaturatingUnsigned(int a, int b) Subtracts twointvalues using saturation arithmetic and numerically treating the values as unsigned. The lower and upper (inclusive) bounds are0and-0xFFFFFFFF, respectively, numerically treating them as unsigned.If the result of the unsigned subtraction would otherwise underflow from the lesser of the two operands to a greater value then the result is clamped to the lower bound
0.- Parameters:
a- the first operand.b- the second operand.- Returns:
- the saturating difference of the operands.
- See Also:
-
minUnsigned
public static short minUnsigned(short a, short b) Returns the smaller of twoshortvalues numerically treating the values as unsigned. That is, the result is the operand closer to the value of the expression0. If the operands have the same value, the result is that same value.- Parameters:
a- the first operand.b- the second operand.- Returns:
- the smaller of
aandb. - See Also:
-
maxUnsigned
public static short maxUnsigned(short a, short b) Returns the greater of twoshortvalues numerically treating the values as unsigned. That is, the result is the operand closer to the value of the expression0xFFFFnumerically treating it as unsigned. If the operands have the same value, the result is that same value.- Parameters:
a- the first operand.b- the second operand.- Returns:
- the larger of
aandb. - See Also:
-
addSaturating
public static short addSaturating(short a, short b) Adds twoshortvalues using saturation arithmetic. The lower and upper (inclusive) bounds areShort.MIN_VALUEandShort.MAX_VALUE, respectively.If the result of the addition would otherwise overflow from a positive value to a negative value then the result is clamped to the upper bound
Short.MAX_VALUE. If the result of the addition would otherwise underflow from a negative value to a positive value then the result is clamped to lower boundShort.MIN_VALUE.- Parameters:
a- the first operand.b- the second operand.- Returns:
- the saturating addition of the operands.
- See Also:
-
subSaturating
public static short subSaturating(short a, short b) Subtracts twoshortvalues using saturation arithmetic. The lower and upper (inclusive) bounds areShort.MIN_VALUEandShort.MAX_VALUE, respectively.If the result of the subtraction would otherwise overflow from a positive value to a negative value then the result is clamped to the upper bound
Short.MAX_VALUE. If the result of the subtraction would otherwise underflow from a negative value to a positive value then the result is clamped to lower boundShort.MIN_VALUE.- Parameters:
a- the first operand.b- the second operand.- Returns:
- the saturating difference of the operands.
- See Also:
-
addSaturatingUnsigned
public static short addSaturatingUnsigned(short a, short b) Adds twoshortvalues using saturation arithmetic and numerically treating the values as unsigned. The lower and upper (inclusive) bounds are0and0xFFFF, respectively, numerically treating them as unsigned.If the result of the unsigned addition would otherwise overflow from the greater of the two operands to a lesser value then the result is clamped to the upper bound
0xFFFF.- Parameters:
a- the first operand.b- the second operand.- Returns:
- the saturating addition of the operands.
- See Also:
-
subSaturatingUnsigned
public static short subSaturatingUnsigned(short a, short b) Subtracts twoshortvalues using saturation arithmetic and numerically treating the values as unsigned. The lower and upper (inclusive) bounds are0and0xFFFF, respectively, numerically treating them as unsigned.If the result of the unsigned subtraction would otherwise underflow from the lesser of the two operands to a greater value then the result is clamped to the lower bound
0.- Parameters:
a- the first operand.b- the second operand.- Returns:
- the saturating difference of the operands.
- See Also:
-
minUnsigned
public static byte minUnsigned(byte a, byte b) Returns the smaller of twobytevalues numerically treating the values as unsigned. That is, the result is the operand closer to the value of the expression0. If the operands have the same value, the result is that same value.- Parameters:
a- the first operand.b- the second operand.- Returns:
- the smaller of
aandb. - See Also:
-
maxUnsigned
public static byte maxUnsigned(byte a, byte b) Returns the greater of twobytevalues numerically treating the values as unsigned. That is, the result is the operand closer to the value of the expression0xFFnumerically treating it as unsigned. If the operands have the same value, the result is that same value.- Parameters:
a- the first operand.b- the second operand.- Returns:
- the larger of
aandb. - See Also:
-
addSaturating
public static byte addSaturating(byte a, byte b) Adds twobytevalues using saturation arithmetic. The lower and upper (inclusive) bounds areByte.MIN_VALUEandByte.MAX_VALUE, respectively.If the result of the addition would otherwise overflow from a positive value to a negative value then the result is clamped to the upper bound
Byte.MAX_VALUE. If the result of the addition would otherwise underflow from a negative value to a positive value then the result is clamped to lower boundByte.MIN_VALUE.- Parameters:
a- the first operand.b- the second operand.- Returns:
- the saturating addition of the operands.
- See Also:
-
subSaturating
public static byte subSaturating(byte a, byte b) Subtracts twobytevalues using saturation arithmetic. The lower and upper (inclusive) bounds areByte.MIN_VALUEandByte.MAX_VALUE, respectively.If the result of the subtraction would otherwise overflow from a positive value to a negative value then the result is clamped to the upper bound
Byte.MAX_VALUE. If the result of the subtraction would otherwise underflow from a negative value to a positive value then the result is clamped to lower boundByte.MIN_VALUE.- Parameters:
a- the first operand.b- the second operand.- Returns:
- the saturating difference of the operands.
- See Also:
-
addSaturatingUnsigned
public static byte addSaturatingUnsigned(byte a, byte b) Adds twobytevalues using saturation arithmetic and numerically treating the values as unsigned. The lower and upper (inclusive) bounds are0and0xFF, respectively, numerically treating them as unsigned.If the result of the unsigned addition would otherwise overflow from the greater of the two operands to a lesser value then the result is clamped to the upper bound
0xFF.- Parameters:
a- the first operand.b- the second operand.- Returns:
- the saturating addition of the operands.
- See Also:
-
subSaturatingUnsigned
public static byte subSaturatingUnsigned(byte a, byte b) Subtracts twobytevalues using saturation arithmetic and numerically treating the values as unsigned. The lower and upper (inclusive) bounds are0and0xFF, respectively, numerically treating them as unsigned.If the result of the unsigned subtraction would otherwise underflow from the lesser of the two operands to a greater value then the result is clamped to the lower bound
0.- Parameters:
a- the first operand.b- the second operand.- Returns:
- the saturating difference of the operands.
- See Also:
-