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


This section documents changes since the first public draft of this specification (0.60, 8 Sep 1997). The classes in the proposal are here called the number class and the context class because their names have changed over time.

Changes in Draft 0.70 (3 May 1998)

  1. The precision of arithmetic required for conforming implementations has been raised from 9 to 100 digits.[1]  The current implementation imposes a limit of 999,999,999 digits.
  2. The two-valued comparator methods in the number class have been replaced by the three-valued compareTo method. The number class now implements the Comparable interface.
  3. The power method in the number class has been renamed pow. This matches the name used in java.lang.Math and java.math.BigInteger.
  4. The context class has been made final and immutable; its set methods have been removed. Its getFormString method has also been removed and a toString method has been added.
  5. The lostdigits field in the context class has been renamed lostDigits to match Java conventions.
  6. The form property of the context class (and related constants) has been changed from type byte to type int to match usual Java practice.

Changes in Draft 0.80 (6 June 1998)

  1. A new round property has been added to the context class, with associated constants and methods. This property is used for selecting rounding algorithms; the constants used for selecting an algorithm have the same values as the constants of the same name in the Java 1.1 java.math.BigDecimal class, and the indicated algorithms have the same semantics.
  2. The number class has been enhanced to implement the rounding algorithms that can be described by a context object. The format method also supports the same rounding algorithms.

Changes in Draft 0.90 (25 June 1998)

This draft is a major update in which the proposed number class is merged with the original BigDecimal class (and renamed BigDecimal), and the context class is renamed.
  1. The following constructors and methods from the BigDecimal class have been added to the number class:
    BigDecimal(BigInteger[,int]), divide(BigDecimal,int[,int]), movePointLeft(int), movePointRight(int), scale(), setScale(int[,int]), toBigInteger(), unscaledValue().
    All the other methods in BigDecimal were already in the number class.
  2. The constant fields describing rounding modes (those whose name starts with ROUND_) have been added to the number class.
  3. A digits value of 0, indicating the use of unlimited-precision fixed-point arithmetic, is now allowed in the context class. With this setting and using form=PLAIN, operators have the same semantics as the original BigDecimal class.
  4. The context class (DecimalContext) has been renamed MathContext as it has no base-10 dependencies in its content (other than illustrative commentary).

Changes in Draft 0.92 (12 July 1998)

This draft is a minor refinement of draft 0.90.
  1. The conversions to and from the floating point primitives are now defined to match their wrapper classes in java.lang. In particular, exponents without a sign will be accepted, and the string form of a BigDecimal constructed from a primitive will be the same as the string constructed using the corresponding wrapper class.
  2. The use of a negative power as the argument to the pow method when digits is 0 is now in error (as the scale used would be 0, leading to a final result of 0 in all cases).
  3. The treatment of trailing zeros is now determined by the form property of the context class, not the digits property.
  4. Minor corrections and clarifications.

Changes in Draft 0.93 (28 October 1998)

This draft contains minor clarifications and editorial changes. There are no functional changes.

Changes in Draft 0.94 (14 December 1998)

This draft is a minor refinement of draft 0.93.
  1. Two methods have been added (for only): a constructor from java.math.BigDecimal, and a toBigDecimal method which converts a number to java.math.BigDecimal.
  2. The description and implementation of the pow (power) method has been changed to conform to ANSI X3.274; the right-hand operand is no longer rounded before use.
  3. Minor clarifications in the description of the format method (no functional changes).

Changes in Draft 0.95 (4 February 1999)

This draft primarily anticipates an errata to ANSI X3.274-1996.
  1. Operands to the operator methods which have more digits than will be used for the calculation are rounded to the specified digits instead of being truncated with a guard digit. (This does not affect the option of causing a lostDigits exception to be thrown instead.)
  2. The description of the result of the BigDecimal(String) constructor when the String includes exponential notation has been clarified.
  3. The format method has been changed from seven underlying methods (allowing all parameters to be optionally omitted from the right) to the two most common forms.

Changes in Draft 0.96 (8 March 1999)

This draft includes a number of simplifications, changes for alignment with Java 1.2 conventions, and changes suggested by users.

Changes in the context class:
  1. The DEFAULT_ constants have been removed, and a new DEFAULT field has been added, to provide a default context for general-purpose arithmetic. The constructor with no arguments is no longer necessary, and has been removed.
  2. The round setting is now called the roundingMode setting, and the corresponding get method is now named getRoundingMode.
  3. The result of the toString method has been modified to make it more readable and self-explanatory.

Changes in the number class:
  1. It is no longer permitted to specify null for a context object, as there is no precedent in the Java core classes for this notation. Instead, the MathContext.DEFAULT object (or a reference to it) should be supplied.
  2. The set of constructors has been simplified, to follow the style of Java core classes, by dropping the constructors from the boolean, byte, char, float, and short primitive types.
  3. The constructors from String and char[] no longer permit embedded blanks, following the precedent in other classes, such as Double(String).
  4. A new constructor from a char[] has been added. This takes an offset and a length, allowing a number embedded in a char array to be converted to a BigDecimal without constructing an intermediate object.
  5. A new valueOf(double) static method has been added, which converts a double to a BigDecimal as though Double.toString() had been used to convert the number to a String, and the BigDecimal(String) constructor had then been used.
  6. The BigDecimal(double) constructor has been deprecated, as its results (now identical to those of the original java.math.BigDecimal(double) constructor) are not consistent with the results of the Double.toString() method.
  7. The methods booleanValue() and charValue() have been removed.
  8. The methods byteValue() (inherited from java.lang.Number), doubleValue(), floatValue(), intValue(), longValue(), and shortValue() (inherited from java.lang.Number) all now act as in Java 1.2; no exception is thrown for numbers that do not have an exact conversion.
  9. The methods byteValueExact(), intValueExact(), longValueExact(), and shortValueExact() have been added; these throw an ArithmeticException if the conversion is not exact (that is, if the number has a non-zero decimal part, or its magnitude is too large).

Changes in Draft 0.97 (13 March 1999)

The method toBigIntegerExact() has been added; this throws an ArithmeticException if the conversion is not exact (that is, if the number has a non-zero decimal part).

Changes in Version 1.04 (10 July 1999)

Minor clarifications; the BigDecimal(String) constructor is limited to exponents of no more than nine digits.
[1] This exceeds the known requirements of current commercial platforms, for example, Oracle Numbers (38 decimal digits), S/390 packed decimals (31 digits), and AS/400 decimals (31 digits).

[previous | contents]