Decimal arithmetic
Copyright (c) IBM Corporation, 2000. All rights reserved. ©
11 Jan 2000
[previous | contents | next]

Methods

The MathContext class has the following public methods for accessing its settings:

getDigits()

Returns a non-negative int which is the value of the digits setting of the MathContext object.

getForm()

Returns an int which is the value of the form setting of the MathContext object. This will be one of ENGINEERING, PLAIN, or SCIENTIFIC.

getLostDigits()

Returns a boolean which is the value of the lostDigits setting of the MathContext object.

getRoundingMode()

Returns an int which is the value of the roundingMode setting of the MathContext object. This will have the value of one of the public constants whose name starts with ROUND_.

toString()

Returns a String representing the settings of the MathContext object as four blank-delimited words separated by a single blank and with no leading or trailing blanks, as follows:

  1. The string digits=, immediately followed by the value of digits as a numeric string.
  2. The string form=, immediately followed by the value of form as a string (one of SCIENTIFIC, PLAIN, or ENGINEERING).
  3. The string lostDigits=, immediately followed by the value of lostDigits (1 for true or 0 for false).
  4. The string roundingMode=, immediately followed by the value of roundingMode as a string. This will be the same as the name of the corresponding public constant.
For example:
  digits=9 form=SCIENTIFIC lostDigits=0 roundingMode=ROUND_HALF_UP
Additional words may be appended to the result of toString in the future if more properties are added to the MathContext class.

[previous | contents | next]