Package org.apfloat

Class Apfloat

java.lang.Object
All Implemented Interfaces:
Serializable, Comparable<Apfloat>, Formattable
Direct Known Subclasses:
Aprational

public class Apfloat extends Apcomplex implements Comparable<Apfloat>
Arbitrary precision floating-point number class.

Apfloat numbers are immutable.

A pitfall exists with the constructors Apfloat(float,long) and Apfloat(double,long). Since floats and doubles are always represented internally in radix 2, the conversion to any other radix usually causes round-off errors, and the resulting apfloat won't be accurate to the desired number of digits.

For example, 0.3 can't be presented exactly in base 2. When you construct an apfloat like new Apfloat(0.3f, 1000), the resulting number won't be accurate to 1000 digits, but only to roughly 7 digits (in radix 10). In fact, the resulting number will be something like 0.30000001192092896...

If you want an exact representation of a floating-point primitive (which is a rational number), you can use Aprational(double).

Version:
1.11.1
Author:
Mikko Tommila
See Also: