public final class TMathContext extends Object implements Serializable
TBigDecimal
.Modifier and Type | Field and Description |
---|---|
static TMathContext |
DECIMAL128
A
MathContext which corresponds to the IEEE 754r quadruple
decimal precision format: 34 digit precision and
TRoundingMode.HALF_EVEN rounding. |
static TMathContext |
DECIMAL32
A
MathContext which corresponds to the IEEE 754r single decimal
precision format: 7 digit precision and TRoundingMode.HALF_EVEN
rounding. |
static TMathContext |
DECIMAL64
A
MathContext which corresponds to the IEEE 754r double decimal
precision format: 16 digit precision and TRoundingMode.HALF_EVEN
rounding. |
static TMathContext |
UNLIMITED
A
MathContext for unlimited precision with
TRoundingMode.HALF_UP rounding. |
Constructor and Description |
---|
TMathContext(int precision)
Constructs a new
MathContext with the specified precision and
with the rounding mode HALF_UP . |
TMathContext(int precision,
TRoundingMode roundingMode)
Constructs a new
MathContext with the specified precision and
with the specified rounding mode. |
TMathContext(String val)
Constructs a new
MathContext from a string. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object x)
Returns true if x is a
MathContext with the same precision
setting and the same rounding mode as this MathContext instance. |
int |
getPrecision()
Returns the precision.
|
TRoundingMode |
getRoundingMode()
Returns the rounding mode.
|
int |
hashCode()
Returns the hash code for this
MathContext instance. |
String |
toString()
Returns the string representation for this
MathContext instance. |
public static final TMathContext DECIMAL128
MathContext
which corresponds to the IEEE 754r quadruple
decimal precision format: 34 digit precision and
TRoundingMode.HALF_EVEN
rounding.public static final TMathContext DECIMAL32
MathContext
which corresponds to the IEEE 754r single decimal
precision format: 7 digit precision and TRoundingMode.HALF_EVEN
rounding.public static final TMathContext DECIMAL64
MathContext
which corresponds to the IEEE 754r double decimal
precision format: 16 digit precision and TRoundingMode.HALF_EVEN
rounding.public static final TMathContext UNLIMITED
MathContext
for unlimited precision with
TRoundingMode.HALF_UP
rounding.public TMathContext(int precision)
MathContext
with the specified precision and
with the rounding mode HALF_UP
. If the
precision passed is zero, then this implies that the computations have to
be performed exact, the rounding mode in this case is irrelevant.precision
- the precision for the new MathContext
.IllegalArgumentException
- if precision < 0
.public TMathContext(int precision, TRoundingMode roundingMode)
MathContext
with the specified precision and
with the specified rounding mode. If the precision passed is zero, then
this implies that the computations have to be performed exact, the
rounding mode in this case is irrelevant.precision
- the precision for the new MathContext
.roundingMode
- the rounding mode for the new MathContext
.IllegalArgumentException
- if precision < 0
.NullPointerException
- if roundingMode
is null
.public TMathContext(String val)
MathContext
from a string. The string has to
specify the precision and the rounding mode to be used and has to follow
the following syntax: "precision=<precision> roundingMode=<roundingMode>"
This is the same form as the one returned by the toString()
method.val
- a string describing the precision and rounding mode for the
new MathContext
.IllegalArgumentException
- if the string is not in the correct format or if the
precision specified is < 0.public int getPrecision()
public TRoundingMode getRoundingMode()
The rounding mode is one of
TRoundingMode.UP
,
TRoundingMode.DOWN
,
TRoundingMode.CEILING
,
TRoundingMode.FLOOR
,
TRoundingMode.HALF_UP
,
TRoundingMode.HALF_DOWN
,
TRoundingMode.HALF_EVEN
, or
TRoundingMode.UNNECESSARY
.
public boolean equals(Object x)
MathContext
with the same precision
setting and the same rounding mode as this MathContext
instance.public int hashCode()
MathContext
instance.public String toString()
MathContext
instance.
The string has the form
"precision=<precision> roundingMode=<roundingMode>"
where <precision>
is an integer describing the number
of digits used for operations and <roundingMode>
is the
string representation of the rounding mode.Copyright © 2019. All rights reserved.