Package org.midheaven.lang
Interface Signed<T>
- Type Parameters:
T- the concrete signed type
- All Known Implementing Classes:
IntAccumulator
public interface Signed<T>
Represents a value that has a mathematical sign and can produce its additive inverse.
-
Method Summary
Modifier and TypeMethodDescriptiondefault Tabs()Returns the absolute value of this instance.default booleanTests if this value is negative.default booleanTests if this value is positive.default booleanisZero()Tests if this value is zero.negate()Returns the additive inverse of this value.intsign()Returns the sign of this value.
-
Method Details
-
sign
int sign()Returns the sign of this value.- Returns:
- a negative value if this value is negative,
0if it is zero, or a positive value if it is positive
-
negate
T negate()Returns the additive inverse of this value.- Returns:
- the negated value
-
isZero
default boolean isZero()Tests if this value is zero.- Returns:
trueifsign()returns0;falseotherwise
-
isPositive
default boolean isPositive()Tests if this value is positive.- Returns:
trueifsign()is greater than0;falseotherwise
-
isNegative
default boolean isNegative()Tests if this value is negative.- Returns:
trueifsign()is less than0;falseotherwise
-
abs
Returns the absolute value of this instance.- Returns:
negate()when this value is negative; otherwise this instance
-