| Package | org.granite.math |
| Class | public final class MathContext |
| Implements | flash.utils.IExternalizable |
BigDecimal class.
The base-independent settings are:
precision:
the number of digits to be used for an operation; results are
rounded to this precision
roundingMode:
a RoundingMode object which specifies the algorithm to be
used for rounding.
java.math.MathContext originally written by
Mike Cowlishaw and Joseph D. Darcy.
See also
| Property | Defined by | ||
|---|---|---|---|
| precision : int [read-only]
The number of digits to be used for an operation.
| MathContext | ||
| roundingMode : RoundingMode
[read-only]
The rounding algorithm to be used for an operation.
| MathContext | ||
| Method | Defined by | ||
|---|---|---|---|
|
MathContext(precision:int = 0, roundingMode:RoundingMode = null)
Constructs a new
MathContext with a specified
precision and rounding mode. | MathContext | ||
|
equals(o:*):Boolean
Compares this
MathContext with the specified
Object for equality. | MathContext | ||
|
forString(s:String):MathContext
[static]
Returns a new
MathContext from a string. | MathContext | ||
|
toString():String
Returns the string representation of this
MathContext. | MathContext | ||
| Constant | Defined by | ||
|---|---|---|---|
| DECIMAL128 : MathContext
[static]
A
MathContext object with a precision setting
matching the IEEE 754R Decimal128 format, 34 digits, and a
rounding mode of RoundingMode.HALF_EVEN, the
IEEE 754R default. | MathContext | ||
| DECIMAL32 : MathContext
[static]
A
MathContext object with a precision setting
matching the IEEE 754R Decimal32 format, 7 digits, and a
rounding mode of RoundingMode.HALF_EVEN, the
IEEE 754R default. | MathContext | ||
| DECIMAL64 : MathContext
[static]
A
MathContext object with a precision setting
matching the IEEE 754R Decimal64 format, 16 digits, and a
rounding mode of RoundingMode.HALF_EVEN, the
IEEE 754R default. | MathContext | ||
| UNLIMITED : MathContext
[static]
A
MathContext object whose settings have the values
required for unlimited precision arithmetic. | MathContext | ||
| precision | property |
precision:int [read-only]
The number of digits to be used for an operation. A value of 0
indicates that unlimited precision (as many digits as are
required) will be used. Note that leading zeros (in the
coefficient of a number) are never significant.
precision will always be non-negative.
public function get precision():int
| roundingMode | property |
roundingMode:RoundingMode [read-only]The rounding algorithm to be used for an operation.
Implementation public function get roundingMode():RoundingMode
See also
| MathContext | () | constructor |
public function MathContext(precision:int = 0, roundingMode:RoundingMode = null)
Constructs a new MathContext with a specified
precision and rounding mode.
precision:int (default = 0) — The non-negative int precision setting.
|
|
roundingMode:RoundingMode (default = null) — The rounding mode to use. If this parameter is
omitted or null, it is defaulted to
RoundingMode.HALF_UP.
|
IllegalArgumentError — if the precision
parameter is less than zero.
|
See also
| equals | () | method |
public function equals(o:*):Boolean
Compares this MathContext with the specified
Object for equality.
o:* — Object to which this MathContext
is to be compared.
|
Boolean — true if and only if the specified
Object is a MathContext object which
has exactly the same settings as this object.
|
| forString | () | method |
public static function forString(s:String):MathContext
Returns a new MathContext from a string.
The string must be in the same format as that produced by the
toString method.
s:String — The string to be parsed
|
MathContext —
a new MathContext instance according to
the supplied parameter.
|
IllegalArgumentError — if the precision section
is out of range or the string is not in the format created by the
toString method.
|
See also
| toString | () | method |
public function toString():String
Returns the string representation of this MathContext.
The String returned represents the settings of the
MathContext object as two space-delimited words
(separated by a single space character, '\u0020',
and with no leading or trailing white space), as follows:
"precision=", immediately followed
by the value of the precision setting as a numeric string as if
generated by the int.toString() method.
"roundingMode=", immediately
followed by the value of the roundingMode setting as a
word. This word will be the same as the name of the
corresponding public constant in the RoundingMode enum.
"precision=9 roundingMode=HALF_UP"
toString in the future if more properties are added to
this class.
Returns
String — a String representing the context settings.
|
See also
| DECIMAL128 | constant |
public static const DECIMAL128:MathContext
A MathContext object with a precision setting
matching the IEEE 754R Decimal128 format, 34 digits, and a
rounding mode of RoundingMode.HALF_EVEN, the
IEEE 754R default.
See also
| DECIMAL32 | constant |
public static const DECIMAL32:MathContext
A MathContext object with a precision setting
matching the IEEE 754R Decimal32 format, 7 digits, and a
rounding mode of RoundingMode.HALF_EVEN, the
IEEE 754R default.
See also
| DECIMAL64 | constant |
public static const DECIMAL64:MathContext
A MathContext object with a precision setting
matching the IEEE 754R Decimal64 format, 16 digits, and a
rounding mode of RoundingMode.HALF_EVEN, the
IEEE 754R default.
See also
| UNLIMITED | constant |
public static const UNLIMITED:MathContext
A MathContext object whose settings have the values
required for unlimited precision arithmetic.
The values of the settings are:
precision=0 roundingMode=HALF_UP
See also