Interface Signed<T>

Type Parameters:
T - the concrete signed type
All Known Subinterfaces:
Int, Rational
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 Type
    Method
    Description
    default T
    abs()
    Returns the absolute value of this instance.
    default boolean
    Tests if this value is negative.
    default boolean
    Tests if this value is positive.
    default boolean
    Tests if this value is zero.
    Returns the additive inverse of this value.
    int
    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, 0 if 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:
      true if sign() returns 0; false otherwise
    • isPositive

      default boolean isPositive()
      Tests if this value is positive.
      Returns:
      true if sign() is greater than 0; false otherwise
    • isNegative

      default boolean isNegative()
      Tests if this value is negative.
      Returns:
      true if sign() is less than 0; false otherwise
    • abs

      default T abs()
      Returns the absolute value of this instance.
      Returns:
      negate() when this value is negative; otherwise this instance