org.jscience.mathematics.algebraic.numbers
Class ExactReal

java.lang.Object
  extended by java.lang.Number
      extended by org.jscience.mathematics.algebraic.numbers.ComparableNumber<ExactReal>
          extended by org.jscience.mathematics.algebraic.numbers.ExactReal
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<ExactReal>, Field.Member, Ring.Member, AbelianGroup.Member, Member

public final class ExactReal
extends ComparableNumber<ExactReal>
implements java.lang.Cloneable, java.io.Serializable, Field.Member

The ExactReal class encapsulates real numbers with infinite precision but slower speed than Float or Double.

See Also:
ExactRealField, Serialized Form

Field Summary
static ExactReal NaN
           
static ExactReal NEGATIVE_INFINITY
           
static ExactReal ONE
          The exact integer representing the multiplicative identity.
static ExactReal POSITIVE_INFINITY
           
static java.lang.Class TYPE
           
static ExactReal ZERO
          The exact integer representing the additive identity.
 
Constructor Summary
ExactReal(java.math.BigDecimal num)
          Constructs a ExactReal number.
ExactReal(double num)
          Constructs a ExactReal number.
ExactReal(Double num)
          Constructs a ExactReal number.
ExactReal(ExactInteger num)
          Constructs a ExactReal number.
ExactReal(ExactRational num)
          Constructs a ExactReal number.
ExactReal(ExactReal num)
          Constructs a ExactReal number.
ExactReal(float num)
          Constructs a ExactReal number.
ExactReal(Float num)
          Constructs a ExactReal number.
ExactReal(int num)
          Constructs a ExactReal number.
ExactReal(Integer num)
          Constructs a ExactReal number.
ExactReal(long num)
          Constructs a ExactReal number.
ExactReal(Long num)
          Constructs a ExactReal number.
ExactReal(Rational num)
          Constructs a ExactReal number.
ExactReal(java.lang.String s)
          Constructs the ExactReal number represented by a string.
 
Method Summary
 ExactReal abs()
          Returns the abs of this number.
 AbelianGroup.Member add(AbelianGroup.Member n)
          Returns the addition of this number and another.
 ExactReal add(ExactReal n)
          Returns the addition of this ExactReal number and another.
 java.lang.Object clone()
          Returns the arc hyperbolic tangent of a number.
 int compareTo(ComparableNumber obj)
          Compares two numbers.
 int compareTo(ExactReal value)
          Compares two ExactReal numbers.
 ExactReal divide(ExactReal n)
          Returns the division of this ExactReal number and another.
 Field.Member divide(Field.Member n)
          Returns the division of this number and another.
 double doubleValue()
           
 boolean equals(java.lang.Object obj)
          Compares two ExactReal numbers for equality.
 float floatValue()
           
 ExactReal getDistance(ComparableNumber n)
          DOCUMENT ME!
 ExactReal getNaN()
          DOCUMENT ME!
 ExactReal getNegativeInfinity()
          DOCUMENT ME!
 ExactReal getPositiveInfinity()
          DOCUMENT ME!
 int hashCode()
          Returns the hashcode of this number.
 int intValue()
           
 Field.Member inverse()
          Returns the inverse of this number.
 boolean isInfinite()
          Returns true if this number is infinite.
 boolean isNaN()
          Returns true if this number is NaN.
 boolean isNegativeInfinity()
          DOCUMENT ME!
 boolean isPositiveInfinity()
          DOCUMENT ME!
 long longValue()
           
 ExactReal max(ExactReal val)
          Returns the max of this number and another, according to compareTo rules.
 ExactReal min(ExactReal val)
          Returns the min of this number and another, according to compareTo rules.
 ExactReal multiply(ExactReal n)
          Returns the multiplication of this ExactReal number and another.
 Ring.Member multiply(Ring.Member n)
          Returns the multiplication of this number and another.
 AbelianGroup.Member negate()
          Returns the negative of this number.
 ExactReal pow(int i)
          Returns this number raised to the power of a number.
 int signum()
          Returns the sign of this number.
 AbelianGroup.Member subtract(AbelianGroup.Member n)
          Returns the subtraction of this number and another.
 ExactReal subtract(ExactReal n)
          Returns the subtraction of this ExactReal number and another.
 java.lang.String toString()
          Returns a string representing the value of this ExactReal number.
 java.math.BigDecimal value()
           
 
Methods inherited from class java.lang.Number
byteValue, shortValue
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ZERO

public static final ExactReal ZERO
The exact integer representing the additive identity.


ONE

public static final ExactReal ONE
The exact integer representing the multiplicative identity.


NEGATIVE_INFINITY

public static final ExactReal NEGATIVE_INFINITY

POSITIVE_INFINITY

public static final ExactReal POSITIVE_INFINITY

NaN

public static final ExactReal NaN

TYPE

public static final java.lang.Class TYPE
Constructor Detail

ExactReal

public ExactReal(ExactReal num)
Constructs a ExactReal number.


ExactReal

public ExactReal(ExactRational num)
Constructs a ExactReal number.


ExactReal

public ExactReal(java.math.BigDecimal num)
Constructs a ExactReal number.


ExactReal

public ExactReal(ExactInteger num)
Constructs a ExactReal number.


ExactReal

public ExactReal(Double num)
Constructs a ExactReal number.


ExactReal

public ExactReal(Float num)
Constructs a ExactReal number.


ExactReal

public ExactReal(Long num)
Constructs a ExactReal number.


ExactReal

public ExactReal(Rational num)
Constructs a ExactReal number.


ExactReal

public ExactReal(Integer num)
Constructs a ExactReal number.


ExactReal

public ExactReal(double num)
Constructs a ExactReal number.


ExactReal

public ExactReal(float num)
Constructs a ExactReal number.


ExactReal

public ExactReal(long num)
Constructs a ExactReal number.


ExactReal

public ExactReal(int num)
Constructs a ExactReal number.


ExactReal

public ExactReal(java.lang.String s)
          throws java.lang.NumberFormatException
Constructs the ExactReal number represented by a string.

Parameters:
s - a string representing a ExactReal number.
Throws:
java.lang.NumberFormatException - if the string does not contain a parsable number.
Method Detail

equals

public boolean equals(java.lang.Object obj)
Compares two ExactReal numbers for equality.

Overrides:
equals in class java.lang.Object
Parameters:
obj - a ExactReal number.

compareTo

public int compareTo(ComparableNumber obj)
              throws java.lang.IllegalArgumentException
Compares two numbers.

Parameters:
obj - a comparable number.
Returns:
a negative value if this<obj, zero if this==obj, and a positive value if this>obj.
Throws:
java.lang.IllegalArgumentException

compareTo

public int compareTo(ExactReal value)
Compares two ExactReal numbers.

Specified by:
compareTo in interface java.lang.Comparable<ExactReal>
Parameters:
value - a ExactReal number.
Returns:
a negative value if this<obj, zero if this==obj, and a positive value if this>obj.

toString

public java.lang.String toString()
Returns a string representing the value of this ExactReal number.

Overrides:
toString in class java.lang.Object

value

public java.math.BigDecimal value()

intValue

public int intValue()
Specified by:
intValue in class java.lang.Number

longValue

public long longValue()
Specified by:
longValue in class java.lang.Number

floatValue

public float floatValue()
Specified by:
floatValue in class java.lang.Number

doubleValue

public double doubleValue()
Specified by:
doubleValue in class java.lang.Number

abs

public ExactReal abs()
Returns the abs of this number.


signum

public int signum()
Returns the sign of this number.


min

public ExactReal min(ExactReal val)
Returns the min of this number and another, according to compareTo rules.

Overrides:
min in class ComparableNumber<ExactReal>
Parameters:
val - DOCUMENT ME!
Returns:
DOCUMENT ME!

max

public ExactReal max(ExactReal val)
Returns the max of this number and another, according to compareTo rules.

Overrides:
max in class ComparableNumber<ExactReal>
Parameters:
val - DOCUMENT ME!
Returns:
DOCUMENT ME!

hashCode

public int hashCode()
Returns the hashcode of this number.

Overrides:
hashCode in class java.lang.Object

isNaN

public boolean isNaN()
Returns true if this number is NaN.

Specified by:
isNaN in class ComparableNumber<ExactReal>
Returns:
DOCUMENT ME!

isInfinite

public boolean isInfinite()
Returns true if this number is infinite.

Specified by:
isInfinite in class ComparableNumber<ExactReal>
Returns:
DOCUMENT ME!

isNegativeInfinity

public boolean isNegativeInfinity()
Description copied from class: ComparableNumber
DOCUMENT ME!

Specified by:
isNegativeInfinity in class ComparableNumber<ExactReal>
Returns:
DOCUMENT ME!

isPositiveInfinity

public boolean isPositiveInfinity()
Description copied from class: ComparableNumber
DOCUMENT ME!

Specified by:
isPositiveInfinity in class ComparableNumber<ExactReal>
Returns:
DOCUMENT ME!

getNaN

public ExactReal getNaN()
Description copied from class: ComparableNumber
DOCUMENT ME!

Specified by:
getNaN in class ComparableNumber<ExactReal>
Returns:
DOCUMENT ME!

getNegativeInfinity

public ExactReal getNegativeInfinity()
Description copied from class: ComparableNumber
DOCUMENT ME!

Specified by:
getNegativeInfinity in class ComparableNumber<ExactReal>
Returns:
DOCUMENT ME!

getPositiveInfinity

public ExactReal getPositiveInfinity()
Description copied from class: ComparableNumber
DOCUMENT ME!

Specified by:
getPositiveInfinity in class ComparableNumber<ExactReal>
Returns:
DOCUMENT ME!

getDistance

public ExactReal getDistance(ComparableNumber n)
Description copied from class: ComparableNumber
DOCUMENT ME!

Specified by:
getDistance in class ComparableNumber<ExactReal>
Parameters:
n - DOCUMENT ME!
Returns:
DOCUMENT ME!

negate

public AbelianGroup.Member negate()
Returns the negative of this number.

Specified by:
negate in interface AbelianGroup.Member
Returns:
DOCUMENT ME!

inverse

public Field.Member inverse()
Returns the inverse of this number.

Specified by:
inverse in interface Field.Member
Returns:
DOCUMENT ME!

add

public AbelianGroup.Member add(AbelianGroup.Member n)
Returns the addition of this number and another.

Specified by:
add in interface AbelianGroup.Member
Parameters:
n - a group member
Returns:
DOCUMENT ME!

add

public ExactReal add(ExactReal n)
Returns the addition of this ExactReal number and another. Adding positive and negative infinity will return NaN.


subtract

public AbelianGroup.Member subtract(AbelianGroup.Member n)
Returns the subtraction of this number and another.

Specified by:
subtract in interface AbelianGroup.Member
Parameters:
n - a group member
Returns:
DOCUMENT ME!

subtract

public ExactReal subtract(ExactReal n)
Returns the subtraction of this ExactReal number and another. Subtracting positive and positive infinity will return NaN. Subtracting negative and negative infinity will return NaN.


multiply

public Ring.Member multiply(Ring.Member n)
Returns the multiplication of this number and another.

Specified by:
multiply in interface Ring.Member
Parameters:
n - a ring member
Returns:
DOCUMENT ME!

multiply

public ExactReal multiply(ExactReal n)
Returns the multiplication of this ExactReal number and another. Multiplying infinity with 0 will return NaN.


divide

public Field.Member divide(Field.Member n)
Returns the division of this number and another.

Specified by:
divide in interface Field.Member
Parameters:
n - a field member
Returns:
DOCUMENT ME!

divide

public ExactReal divide(ExactReal n)
Returns the division of this ExactReal number and another. Dividing infinity with infinity will return NaN.


pow

public ExactReal pow(int i)
Returns this number raised to the power of a number.


clone

public java.lang.Object clone()
Returns the arc hyperbolic tangent of a number.

Overrides:
clone in class java.lang.Object