JScience v3.3

org.jscience.mathematics.numbers
Class Number<T extends Number<T>>

java.lang.Object
  extended by javolution.context.RealtimeObject
      extended by org.jscience.mathematics.numbers.Number<T>
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<T>, Realtime, Immutable, GroupAdditive<T>, Ring<T>, Structure<T>
Direct Known Subclasses:
Complex, Float64, Integer64, LargeInteger, ModuloInteger, Rational, Real

public abstract class Number<T extends Number<T>>
extends RealtimeObject
implements Ring<T>, java.lang.Comparable<T>, Immutable

This class represents an immutable number.

Instances of this class are typically created using real-time factories.

Version:
3.0, February 13, 2006
Author:
Jean-Marie Dautelle
See Also:
Wikipedia: Number, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javolution.context.RealtimeObject
RealtimeObject.Factory<T extends RealtimeObject>
 
Nested classes/interfaces inherited from interface javolution.context.Realtime
Realtime.ObjectSpace
 
Constructor Summary
Number()
           
 
Method Summary
 byte byteValue()
          Returns the value of this number as a byte.
abstract  int compareTo(T that)
          Compares this number with the specified number for order.
abstract  double doubleValue()
          Returns the value of this number as a double.
abstract  boolean equals(java.lang.Object obj)
          Indicates if this number is equals to the specified object.
 float floatValue()
          Returns the value of this number as a float.
abstract  int hashCode()
          Returns the hash code for this number (consistent with equals(Object).
 int intValue()
          Returns the value of this number as an int.
 boolean isGreaterThan(T that)
          Indicates if this number is ordered after that number (convenience method).
abstract  boolean isLargerThan(T that)
          Compares the magnitude of this number with that number.
 boolean isLessThan(T that)
          Indicates if this number is ordered before that number (convenience method).
abstract  long longValue()
          Returns the value of this number as a long.
 T minus(T that)
          Returns the difference between this number and the one specified.
 boolean move(Realtime.ObjectSpace os)
          Moves this real-time object to the specified object space.
 T pow(int exp)
          Returns this number raised at the specified positive exponent.
 short shortValue()
          Returns the value of this number as a short.
abstract  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).
 
Methods inherited from class javolution.context.RealtimeObject
export, isLocal, moveHeap, preserve, toString, unpreserve
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jscience.mathematics.structures.Ring
times
 
Methods inherited from interface org.jscience.mathematics.structures.GroupAdditive
opposite, plus
 

Constructor Detail

Number

public Number()
Method Detail

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.

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.

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 java.lang.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:
java.lang.IllegalArgumentException - if exp <= 0

byteValue

public final byte byteValue()
Returns the value of this number as a byte. This may involve rounding or truncation.

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.

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.

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.

Returns:
the numeric value represented by this object after conversion to type float.

equals

public abstract boolean equals(java.lang.Object obj)
Indicates if this number is equals to the specified object.

Overrides:
equals in class java.lang.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 java.lang.Object
Returns:
this number hash code.

toText

public abstract 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 Realtime
Overrides:
toText in class RealtimeObject
Returns:
this object's textual representation.

move

public boolean move(Realtime.ObjectSpace os)
Moves this real-time object to the specified object space.

Specified by:
move in interface Realtime
Overrides:
move in class RealtimeObject
Parameters:
os - the object space to move this real-time object to.
Returns:
true if the move has to be propagated to external real-time references; false otherwise.

JScience v3.3

Copyright © 2006 JScience.