Class Number<T extends Number<T>>

java.lang.Object
java.lang.Number
org.jscience.mathematics.number.Number<T>
All Implemented Interfaces:
Serializable, Comparable<T>, javolution.lang.Immutable, javolution.lang.Realtime, javolution.lang.ValueType, javolution.xml.XMLSerializable, GroupAdditive<T>, Ring<T>, Structure<T>
Direct Known Subclasses:
Complex, Float64, FloatingPoint, Integer64, LargeInteger, ModuloInteger, Rational, Real

public abstract class Number<T extends Number<T>> extends Number implements Ring<T>, Comparable<T>, javolution.lang.Realtime, javolution.xml.XMLSerializable

This class represents a value-type number.

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final byte
    Returns the value of this number as a byte.
    abstract int
    compareTo(T that)
    Compares this number with the specified number for order.
    abstract Number<T>
    Returns a copy of this number allocated by the calling thread (possibly on the stack).
    abstract double
    Returns the value of this number as a double.
    abstract boolean
    Indicates if this number is equals to the specified object.
    final float
    Returns the value of this number as a float.
    abstract int
    Returns the hash code for this number (consistent with equals(Object).
    final int
    Returns the value of this number as an int.
    final boolean
    Indicates if this number is ordered after that number (convenience method).
    abstract boolean
    Compares the magnitude of this number with that number.
    final boolean
    isLessThan(T that)
    Indicates if this number is ordered before that number (convenience method).
    abstract long
    Returns the value of this number as a long.
    minus(T that)
    Returns the difference between this number and the one specified.
    pow(int exp)
    Returns this number raised at the specified positive exponent.
    final short
    Returns the value of this number as a short.
    final String
    Returns the text representation of this number as a java.lang.String.
    abstract javolution.text.Text
    Returns the textual representation of this real-time object (equivalent to toString except that the returned value can be allocated from the local context space).

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.jscience.mathematics.structure.GroupAdditive

    opposite, plus

    Methods inherited from interface org.jscience.mathematics.structure.Ring

    times
  • Constructor Details

    • Number

      public Number()
  • Method Details

    • isLargerThan

      public abstract boolean isLargerThan(T that)
      Compares the magnitude of this number with that number.
      Returns:
      |this| > |that|
    • longValue

      public abstract long longValue()
      Returns the value of this number as a long.
      Specified by:
      longValue in class Number
      Returns:
      the numeric value represented by this object after conversion to type long.
    • doubleValue

      public abstract double doubleValue()
      Returns the value of this number as a double.
      Specified by:
      doubleValue in class Number
      Returns:
      the numeric value represented by this object after conversion to type double.
    • compareTo

      public abstract int compareTo(T that)
      Compares this number with the specified number for order. Returns a negative integer, zero, or a positive integer as this number is less than, equal to, or greater than the specified number. Implementation must ensure that this method is consistent with equals (x.compareTo(y)==0) == (x.equals(y)),
      Specified by:
      compareTo in interface Comparable<T extends Number<T>>
      Parameters:
      that - the number to be compared.
      Returns:
      a negative integer, zero, or a positive integer as this number is less than, equal to, or greater than the specified number.
    • isLessThan

      public final boolean isLessThan(T that)
      Indicates if this number is ordered before that number (convenience method).
      Parameters:
      that - the number to compare with.
      Returns:
      this.compareTo(that) < 0.
    • isGreaterThan

      public final boolean isGreaterThan(T that)
      Indicates if this number is ordered after that number (convenience method).
      Parameters:
      that - the number to compare with.
      Returns:
      this.compareTo(that) > 0.
    • minus

      public T minus(T that)
      Returns the difference between this number and the one specified.
      Parameters:
      that - the number to be subtracted.
      Returns:
      this - that.
    • pow

      public T pow(int exp)
      Returns this number raised at the specified positive exponent.
      Parameters:
      exp - the positive exponent.
      Returns:
      thisexp
      Throws:
      IllegalArgumentException - if exp <= 0
    • byteValue

      public final byte byteValue()
      Returns the value of this number as a byte. This may involve rounding or truncation.
      Overrides:
      byteValue in class Number
      Returns:
      the numeric value represented by this object after conversion to type byte.
    • shortValue

      public final short shortValue()
      Returns the value of this number as a short. This may involve rounding or truncation.
      Overrides:
      shortValue in class Number
      Returns:
      the numeric value represented by this object after conversion to type short.
    • intValue

      public final int intValue()
      Returns the value of this number as an int. This may involve rounding or truncation.
      Specified by:
      intValue in class Number
      Returns:
      the numeric value represented by this object after conversion to type int.
    • floatValue

      public final float floatValue()
      Returns the value of this number as a float. This may involve rounding.
      Specified by:
      floatValue in class Number
      Returns:
      the numeric value represented by this object after conversion to type float.
    • equals

      public abstract boolean equals(Object obj)
      Indicates if this number is equals to the specified object.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object to be compared with.
      Returns:
      true if this number and the specified argument represent the same number; false otherwise.
    • hashCode

      public abstract int hashCode()
      Returns the hash code for this number (consistent with equals(Object).
      Overrides:
      hashCode in class Object
      Returns:
      this number hash code.
    • toText

      public abstract javolution.text.Text toText()
      Returns the textual representation of this real-time object (equivalent to toString except that the returned value can be allocated from the local context space).
      Specified by:
      toText in interface javolution.lang.Realtime
      Returns:
      this object's textual representation.
    • copy

      public abstract Number<T> copy()
      Returns a copy of this number allocated by the calling thread (possibly on the stack).
      Specified by:
      copy in interface javolution.lang.ValueType
      Returns:
      an identical and independant copy of this number.
    • toString

      public final String toString()
      Returns the text representation of this number as a java.lang.String.
      Overrides:
      toString in class Object
      Returns:
      toText().toString()