
ArciMath BigDecimal v2.05 now with BigDecimalFormat 

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: INNER  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
java.lang.Object  +be.arci.math.MathContext
The immutable class MathContext contains the arithmetic settings understood by the operator methods of the BigDecimal class (and potentially other classes). Operator methods are those that effect an operation on a number or a pair of numbers.
The settings comprise:
When MathContext.DEFAULT is provided for a MathContext parameter then the default settings are used, to know digits=9, form=SCIENTIFIC, lostDigits=false, roundingMode=ROUND_HALF_UP.
All methods of the BigDecimal class which accept a MathContext parameter also have a signature of the method which does not accept a MathContext parameter; the methods with that signature carry out unlimited precision fixed point arithmetic, as with the settings digits=0, form=PLAIN, lostDigits=false, roundingMode=ROUND_HALF_UP. This provides backward compatibility with the java.math.BigDecimal class.
The rounding mode can have the same values as the ROUND_ constants of java.math.BigDecimal and be.arci.math.BigDecimal, to ease switching over. We recommend using the definitions for these constants that are in this class.
BigDecimal
, Serialized FormField Summary  
static MathContext 
DEFAULT
The default context, which is digits=9, form=SCIENTIFIC, lostDigits=false, roundingMode=ROUND_HALF_UP, settings well suited for generalpurpose arithmetic. 
static int 
ENGINEERING
Floating point notation (with engineering exponential format, having one to three digits before any decimal point, such that the power of ten in an eventual exponent is a multiple of 3). 
static int 
PLAIN
Plain fixed point notation, without any exponent. 
static int 
ROUND_CEILING
Rounding mode to round towards positive infinity. 
static int 
ROUND_DOWN
Rounding mode to round towards zero. 
static int 
ROUND_FLOOR
Rounding mode to round towards negative infinity. 
static int 
ROUND_HALF_DOWN
Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round down. 
static int 
ROUND_HALF_EVEN
Rounding mode to round towards the "nearest neighbor" unless both neighbors are equidistant, in which case, round towards the even neighbor. 
static int 
ROUND_HALF_UP
Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round up. 
static int 
ROUND_UNNECESSARY
Rounding mode to assert that the requested operation has an exact result, hence no rounding is necessary. 
static int 
ROUND_UP
Rounding mode to round away from zero. 
static int 
SCIENTIFIC
Floating point notation (with scientific exponential format, where there is one digit before any decimal point). 
Constructor Summary  
MathContext(int digits)
Constructs a new MathContext with a specified precision. 

MathContext(int digits,
int form)
Constructs a new MathContext with a specified precision and form of notation. 

MathContext(int digits,
int form,
boolean swLostDigits)
Constructs a new MathContext with a specified precision, form of notation and assertion for lost digits. 

MathContext(int digits,
int form,
boolean swLostDigits,
int roundingMode)
Constructs a new MathContext with a specified precision, form of notation, assertion for lost digits and rounding mode. 
Method Summary  
int 
getDigits()
Returns the precision in digits; this value is always nonnegative. 
int 
getForm()
Returns the form or notation setting; this will be one of the constants ENGINEERING, PLAIN or SCIENTIFIC. 
boolean 
getLostDigits()
Returns the lostDigits assertion setting. 
int 
getRoundingMode()
Returns the rounding mode setting; this will be one of the ROUND_ constants 
java.lang.String 
toString()
Returns the MathContext as a readable string. 
Methods inherited from class java.lang.Object 
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait 
Field Detail 
public static final int PLAIN
SCIENTIFIC
,
ENGINEERING
public static final int SCIENTIFIC
PLAIN
,
ENGINEERING
public static final int ENGINEERING
SCIENTIFIC
,
PLAIN
public static final int ROUND_UP
BigDecimal.ROUND_UP
public static final int ROUND_DOWN
BigDecimal.ROUND_DOWN
public static final int ROUND_CEILING
BigDecimal.ROUND_CEILING
public static final int ROUND_FLOOR
BigDecimal.ROUND_FLOOR
public static final int ROUND_HALF_UP
BigDecimal.ROUND_HALF_UP
public static final int ROUND_HALF_DOWN
BigDecimal.ROUND_HALF_DOWN
public static final int ROUND_HALF_EVEN
BigDecimal.ROUND_HALF_EVEN
public static final int ROUND_UNNECESSARY
BigDecimal.ROUND_UNNECESSARY
public static final MathContext DEFAULT
Constructor Detail 
public MathContext(int digits)
digits
 The precision in digits for this MathContext; must be
in the range 0 ≤ digits ≤ 999999999.java.lang.IllegalArgumentException
 parameter out of range.DEFAULT
public MathContext(int digits, int form)
digits
 The precision in digits for this MathContext; must be
in the range 0 ≤ digits ≤ 999999999.form
 The form or notation for this MathContext, which must be
one of the constants PLAIN, SCIENTIFIC or ENGINEERING.java.lang.IllegalArgumentException
 parameter out of range.DEFAULT
,
PLAIN
,
SCIENTIFIC
,
ENGINEERING
public MathContext(int digits, int form, boolean swLostDigits)
digits
 The precision in digits for this MathContext; must be
in the range 0 ≤ digits ≤ 999999999.form
 The form or notation for this MathContext, which must be
one of the constants PLAIN, SCIENTIFIC or ENGINEERING.lostDigits
 true if assertion for not loosing nonzero digits
is needed.java.lang.IllegalArgumentException
 parameter out of range.DEFAULT
,
PLAIN
,
SCIENTIFIC
,
ENGINEERING
public MathContext(int digits, int form, boolean swLostDigits, int roundingMode)
digits
 The precision in digits for this MathContext; must be
in the range 0 ≤ digits ≤ 999999999.form
 The form or notation for this MathContext, which must be
one of the constants PLAIN, SCIENTIFIC or ENGINEERING.lostDigits
 true if assertion for not loosing nonzero digits
is needed.roundingMode
 The roundingMode setting for this MathContext,
which must be one of the ROUND_ constants.java.lang.IllegalArgumentException
 parameter out of range.PLAIN
,
SCIENTIFIC
,
ENGINEERING
Method Detail 
public int getDigits()
public int getForm()
PLAIN
,
SCIENTIFIC
,
ENGINEERING
public boolean getLostDigits()
public int getRoundingMode()
public java.lang.String toString()
toString
in class java.lang.Object

ArciMath BigDecimal v2.05 now with BigDecimalFormat 

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: INNER  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 