Package org.jscience.mathematics.algebraic.numbers

Provides common types of numbers.


Class Summary
BigRational BigRational: dynamically sized immutable arbitrary-precision rational numbers.
Boolean The Boolean class encapsulates Boolean numbers.
ComparableNumber<T extends ComparableNumber> This is the superclass for comparable numbers.
Complex The Complex class encapsulates complex numbers.
Double The Double class encapsulates double numbers.
ExactComplex The ExactComplex class encapsulates complex numbers using ExactReals for real and imaginary part.
ExactInteger The ExactInteger class encapsulates integer numbers with infinite precision but slower speed than Integer or Long.
ExactQuaternion The ExactQuaternion class encapsulates quaternions.
ExactRational The ExactRational class encapsulates rational numbers with infinite precision.
ExactReal The ExactReal class encapsulates real numbers with infinite precision but slower speed than Float or Double.
ExactSupernumber The ExactSupernumber class encapsulates supernumbers.
Float The Float class encapsulates float numbers.
Integer The Integer class encapsulates integer numbers.
Long The Long class encapsulates 64 bits integer numbers.
Quaternion The Quaternion class encapsulates quaternions.
RadixConverter DOCUMENT ME!
Supernumber The Supernumber class encapsulates supernumbers.

Package org.jscience.mathematics.algebraic.numbers Description

Provides common types of numbers.

Although numbers defined in this package are not as fast as primitives types (e.g. int or double). They have many advantages (such as arbitrary size or precision) which make them irreplaceable in some calculations. This can be illustrated with the following example:

        double x = 10864;
        double y = 18817;
        double z = 9 * Math.pow(x, 4.0)- Math.pow(y, 4.0) + 2 * Math.pow(y, 2.0);
        System.out.println("Result : " + z);

        > Result : 2.0
The mathematically correct value is z=1. However, Java compilers using ANSI/IEEE double precision numbers evaluate z=2. Not even the first digit is correct! This is due to a rounding error occurring when subtracting two nearly equal floating point numbers. Now, lets write the same formula using ExactReal numbers:
        ExactReal x = new ExactReal(10864);
        ExactReal y = new ExactReal(18817);
        ExactReal z = (ExactReal) new ExactReal(9).times(x.pow(4)).plus(y.pow(4).opposite()).plus(new ExactReal(2).times(y.pow(2)));
        System.out.println("Result : " + z);

        > Result   : 1.000
Not only the correct result is returned, but this result is also guaranteed to be 1 ± 0.001 (only exact digits are written out).