|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.math.dfp.DfpField
public class DfpField
Field for Decimal floating point instances.
Nested Class Summary | |
---|---|
static class |
DfpField.RoundingMode
Enumerate for rounding modes. |
Field Summary | |
---|---|
private Dfp |
e
A Dfp with value e. |
private Dfp[] |
eSplit
A two elements Dfp array with value e split in two pieces. |
private static String |
eString
High precision string representation of e. |
static int |
FLAG_DIV_ZERO
IEEE 854-1987 flag for division by zero. |
static int |
FLAG_INEXACT
IEEE 854-1987 flag for inexact result. |
static int |
FLAG_INVALID
IEEE 854-1987 flag for invalid operation. |
static int |
FLAG_OVERFLOW
IEEE 854-1987 flag for overflow. |
static int |
FLAG_UNDERFLOW
IEEE 854-1987 flag for underflow. |
private int |
ieeeFlags
IEEE 854-1987 signals. |
private Dfp |
ln10
A Dfp with value ln(10). |
private static String |
ln10String
High precision string representation of ln(10). |
private Dfp |
ln2
A Dfp with value ln(2). |
private Dfp[] |
ln2Split
A two elements Dfp array with value ln(2) split in two pieces. |
private static String |
ln2String
High precision string representation of ln(2). |
private Dfp |
ln5
A Dfp with value ln(5). |
private Dfp[] |
ln5Split
A two elements Dfp array with value ln(5) split in two pieces. |
private static String |
ln5String
High precision string representation of ln(5). |
private Dfp |
one
A Dfp with value 1. |
private Dfp |
pi
A Dfp with value π. |
private Dfp[] |
piSplit
A two elements Dfp array with value π split in two pieces. |
private static String |
piString
High precision string representation of π. |
private int |
radixDigits
The number of radix digits. |
private DfpField.RoundingMode |
rMode
Current rounding mode. |
private Dfp |
sqr2
A Dfp with value √2. |
private Dfp |
sqr2Reciprocal
A Dfp with value √2 / 2. |
private static String |
sqr2ReciprocalString
High precision string representation of √2 / 2. |
private Dfp[] |
sqr2Split
A two elements Dfp array with value √2 split in two pieces. |
private static String |
sqr2String
High precision string representation of √2. |
private Dfp |
sqr3
A Dfp with value √3. |
private Dfp |
sqr3Reciprocal
A Dfp with value √3 / 3. |
private static String |
sqr3ReciprocalString
High precision string representation of √3 / 3. |
private static String |
sqr3String
High precision string representation of √3. |
private Dfp |
two
A Dfp with value 2. |
private Dfp |
zero
A Dfp with value 0. |
Constructor Summary | |
---|---|
|
DfpField(int decimalDigits)
Create a factory for the specified number of radix digits. |
private |
DfpField(int decimalDigits,
boolean computeConstants)
Create a factory for the specified number of radix digits. |
Method Summary | |
---|---|
void |
clearIEEEFlags()
Clears the IEEE 854 status flags. |
static Dfp |
computeExp(Dfp a,
Dfp one)
Compute exp(a). |
static Dfp |
computeLn(Dfp a,
Dfp one,
Dfp two)
Compute ln(a). |
private static Dfp |
computePi(Dfp one,
Dfp two,
Dfp three)
Compute π using Jonathan and Peter Borwein quartic formula. |
private static void |
computeStringConstants(int highPrecisionDecimalDigits)
Recompute the high precision string constants. |
Dfp |
getE()
Get the constant e. |
Dfp[] |
getESplit()
Get the constant e split in two pieces. |
int |
getIEEEFlags()
Get the IEEE 854 status flags. |
Dfp |
getLn10()
Get the constant ln(10). |
Dfp |
getLn2()
Get the constant ln(2). |
Dfp[] |
getLn2Split()
Get the constant ln(2) split in two pieces. |
Dfp |
getLn5()
Get the constant ln(5). |
Dfp[] |
getLn5Split()
Get the constant ln(5) split in two pieces. |
Dfp |
getOne()
Get the constant 1. |
Dfp |
getPi()
Get the constant π. |
Dfp[] |
getPiSplit()
Get the constant π split in two pieces. |
int |
getRadixDigits()
Get the number of radix digits of the Dfp instances built by this factory. |
DfpField.RoundingMode |
getRoundingMode()
Get the current rounding mode. |
Dfp |
getSqr2()
Get the constant √2. |
Dfp |
getSqr2Reciprocal()
Get the constant √2 / 2. |
Dfp[] |
getSqr2Split()
Get the constant √2 split in two pieces. |
Dfp |
getSqr3()
Get the constant √3. |
Dfp |
getSqr3Reciprocal()
Get the constant √3 / 3. |
Dfp |
getTwo()
Get the constant 2. |
Dfp |
getZero()
Get the constant 0. |
Dfp |
newDfp()
Makes a Dfp with a value of 0. |
Dfp |
newDfp(byte x)
Create an instance from a byte value. |
Dfp |
newDfp(byte sign,
byte nans)
Creates a Dfp with a non-finite value. |
Dfp |
newDfp(Dfp d)
Copy constructor. |
Dfp |
newDfp(double x)
Create an instance from a double value. |
Dfp |
newDfp(int x)
Create an instance from an int value. |
Dfp |
newDfp(long x)
Create an instance from a long value. |
Dfp |
newDfp(String s)
Create a Dfp given a String representation. |
void |
setIEEEFlags(int flags)
Sets the IEEE 854 status flags. |
void |
setIEEEFlagsBits(int bits)
Sets some bits in the IEEE 854 status flags, without changing the already set bits. |
void |
setRoundingMode(DfpField.RoundingMode mode)
Set the rounding mode. |
private Dfp[] |
split(String a)
Breaks a string representation up into two Dfp 's. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int FLAG_INVALID
public static final int FLAG_DIV_ZERO
public static final int FLAG_OVERFLOW
public static final int FLAG_UNDERFLOW
public static final int FLAG_INEXACT
private static String sqr2String
private static String sqr2ReciprocalString
private static String sqr3String
private static String sqr3ReciprocalString
private static String piString
private static String eString
private static String ln2String
private static String ln5String
private static String ln10String
private final int radixDigits
private final Dfp zero
Dfp
with value 0.
private final Dfp one
Dfp
with value 1.
private final Dfp two
Dfp
with value 2.
private final Dfp sqr2
Dfp
with value √2.
private final Dfp[] sqr2Split
Dfp
array with value √2 split in two pieces.
private final Dfp sqr2Reciprocal
Dfp
with value √2 / 2.
private final Dfp sqr3
Dfp
with value √3.
private final Dfp sqr3Reciprocal
Dfp
with value √3 / 3.
private final Dfp pi
Dfp
with value π.
private final Dfp[] piSplit
Dfp
array with value π split in two pieces.
private final Dfp e
Dfp
with value e.
private final Dfp[] eSplit
Dfp
array with value e split in two pieces.
private final Dfp ln2
Dfp
with value ln(2).
private final Dfp[] ln2Split
Dfp
array with value ln(2) split in two pieces.
private final Dfp ln5
Dfp
with value ln(5).
private final Dfp[] ln5Split
Dfp
array with value ln(5) split in two pieces.
private final Dfp ln10
Dfp
with value ln(10).
private DfpField.RoundingMode rMode
private int ieeeFlags
Constructor Detail |
---|
public DfpField(int decimalDigits)
Note that since the Dfp
class uses 10000 as its radix, each radix
digit is equivalent to 4 decimal digits. This implies that asking for
13, 14, 15 or 16 decimal digits will really lead to a 4 radix 10000 digits in
all cases.
decimalDigits
- minimal number of decimal digits.private DfpField(int decimalDigits, boolean computeConstants)
Note that since the Dfp
class uses 10000 as its radix, each radix
digit is equivalent to 4 decimal digits. This implies that asking for
13, 14, 15 or 16 decimal digits will really lead to a 4 radix 10000 digits in
all cases.
decimalDigits
- minimal number of decimal digitscomputeConstants
- if true, the transcendental constants for the given precision
must be computed (setting this flag to false is RESERVED for the internal recursive call)Method Detail |
---|
public int getRadixDigits()
Dfp
instances built by this factory.
public void setRoundingMode(DfpField.RoundingMode mode)
DfpField.RoundingMode.ROUND_HALF_EVEN
.
mode
- desired rounding mode
Note that the rounding mode is common to all Dfp
instances
belonging to the current DfpField
in the system and will
affect all future calculations.public DfpField.RoundingMode getRoundingMode()
public int getIEEEFlags()
clearIEEEFlags()
,
setIEEEFlags(int)
,
setIEEEFlagsBits(int)
,
FLAG_INVALID
,
FLAG_DIV_ZERO
,
FLAG_OVERFLOW
,
FLAG_UNDERFLOW
,
FLAG_INEXACT
public void clearIEEEFlags()
getIEEEFlags()
,
setIEEEFlags(int)
,
setIEEEFlagsBits(int)
,
FLAG_INVALID
,
FLAG_DIV_ZERO
,
FLAG_OVERFLOW
,
FLAG_UNDERFLOW
,
FLAG_INEXACT
public void setIEEEFlags(int flags)
flags
- desired value for the flagsgetIEEEFlags()
,
clearIEEEFlags()
,
setIEEEFlagsBits(int)
,
FLAG_INVALID
,
FLAG_DIV_ZERO
,
FLAG_OVERFLOW
,
FLAG_UNDERFLOW
,
FLAG_INEXACT
public void setIEEEFlagsBits(int bits)
Calling this method is equivalent to call setIEEEFlags(getIEEEFlags() | bits)
bits
- bits to setgetIEEEFlags()
,
clearIEEEFlags()
,
setIEEEFlags(int)
,
FLAG_INVALID
,
FLAG_DIV_ZERO
,
FLAG_OVERFLOW
,
FLAG_UNDERFLOW
,
FLAG_INEXACT
public Dfp newDfp()
Dfp
with a value of 0.
Dfp
with a value of 0public Dfp newDfp(byte x)
x
- value to convert to an instance
Dfp
with the same value as xpublic Dfp newDfp(int x)
x
- value to convert to an instance
Dfp
with the same value as xpublic Dfp newDfp(long x)
x
- value to convert to an instance
Dfp
with the same value as xpublic Dfp newDfp(double x)
x
- value to convert to an instance
Dfp
with the same value as xpublic Dfp newDfp(Dfp d)
d
- instance to copy
Dfp
with the same value as dpublic Dfp newDfp(String s)
Dfp
given a String representation.
s
- string representation of the instance
Dfp
parsed from specified stringpublic Dfp newDfp(byte sign, byte nans)
Dfp
with a non-finite value.
sign
- sign of the Dfp to createnans
- code of the value, must be one of Dfp.INFINITE
,
Dfp.SNAN
, Dfp.QNAN
Dfp
with a non-finite valuepublic Dfp getZero()
getZero
in interface Field<Dfp>
Dfp
with value 0public Dfp getOne()
getOne
in interface Field<Dfp>
Dfp
with value 1public Dfp getTwo()
Dfp
with value 2public Dfp getSqr2()
Dfp
with value √2public Dfp[] getSqr2Split()
Dfp
with value √2 split in two piecespublic Dfp getSqr2Reciprocal()
Dfp
with value √2 / 2public Dfp getSqr3()
Dfp
with value √3public Dfp getSqr3Reciprocal()
Dfp
with value √3 / 3public Dfp getPi()
Dfp
with value πpublic Dfp[] getPiSplit()
Dfp
with value π split in two piecespublic Dfp getE()
Dfp
with value epublic Dfp[] getESplit()
Dfp
with value e split in two piecespublic Dfp getLn2()
Dfp
with value ln(2)public Dfp[] getLn2Split()
Dfp
with value ln(2) split in two piecespublic Dfp getLn5()
Dfp
with value ln(5)public Dfp[] getLn5Split()
Dfp
with value ln(5) split in two piecespublic Dfp getLn10()
Dfp
with value ln(10)private Dfp[] split(String a)
Dfp
's.
The split is such that the sum of them is equivalent to the input string,
but has higher precision than using a single Dfp.
a
- string representation of the number to split
Dfp
instances which sum equals aprivate static void computeStringConstants(int highPrecisionDecimalDigits)
highPrecisionDecimalDigits
- precision at which the string constants mus be computedprivate static Dfp computePi(Dfp one, Dfp two, Dfp three)
one
- constant with value 1 at desired precisiontwo
- constant with value 2 at desired precisionthree
- constant with value 3 at desired precision
public static Dfp computeExp(Dfp a, Dfp one)
a
- number for which we want the exponentialone
- constant with value 1 at desired precision
public static Dfp computeLn(Dfp a, Dfp one, Dfp two)
a
- number for which we want the exponentialone
- constant with value 1 at desired precisiontwo
- constant with value 2 at desired precision
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |