Class ANumeric

All Implemented Interfaces:
IValidated, IWriteable, Comparable<ANumeric>
Direct Known Subclasses:
AInteger, CVMDouble

public abstract class ANumeric extends APrimitive implements Comparable<ANumeric>
BAse class for CVM numeric types
  • Constructor Details

    • ANumeric

      public ANumeric()
  • Method Details

    • toLong

      public abstract CVMLong toLong()
      Casts to a CVM Long value. Takes last 64 bits.
      Returns:
      Long representation of this number
    • toDouble

      public abstract CVMDouble toDouble()
      Casts to a CVM Double value.
      Returns:
      Double value
    • doubleValue

      public abstract double doubleValue()
      Specified by:
      doubleValue in class APrimitive
      Returns:
      Java double value representing this primitive CVM value
    • numericType

      public abstract Class<?> numericType()
      Gets the numeric type that should be used as for calculations
      Returns:
      Double.class or Long.class, or null if not a numeric type
    • signum

      public abstract APrimitive signum()
      Gets the signum of this numerical value. Will be -1, 0 or 1 for Longs, -1.0, 0.0 , 1.0 or ##NaN for Doubles.
      Returns:
      Signum of the numeric value
    • abs

      public abstract ANumeric abs()
      Gets the absolute value of this number. May be ##NaN for Doubles.
      Returns:
      Absolute value of the numeric value
    • ensureLong

      public abstract CVMLong ensureLong()
      Gets the numeric value as a Long integer, or null if not a valid Long
      Returns:
      CVMLong value, or null
    • add

      public abstract ANumeric add(ANumeric b)
      Adds a second numeric value to this value
      Parameters:
      b - Second number to add
      Returns:
      Result of addition
    • sub

      public abstract ANumeric sub(ANumeric b)
      Subtracts a second numeric value to this value
      Parameters:
      b - Number to subtract
      Returns:
      Result of subtraction
    • negate

      public abstract ANumeric negate()
      Negates this numeric value
      Returns:
      Negated value
    • multiply

      public abstract ANumeric multiply(ANumeric b)
      Multiplies a second numeric value with this value
      Parameters:
      b - Second number to add
      Returns:
      Result of multiplication
    • toInteger

      public abstract AInteger toInteger()
      Converts this numeric value to the nearest integer
      Returns:
      Integer value
    • isZero

      public abstract boolean isZero()
      Check if this numeric value is equal to zero
      Returns:
      True if this value is numerically equal to zero