Java Reference
In-Depth Information
TABLE 8.6 COMMON MATH FUNCTIONS IN JAVA AND COBOL
Method
Description
COBOL Equivalent
int compareTo
Compares this BigDecimal with
IF
PACKED-NUM1
=
(BigDecimal val)
another BigDecimal
PACKED-NUM2
BigDecimal add
Returns a BigDecimal whose value
ADD
PACKED-NUM1
TO
(BigDecimal val)
is (this + val), and whose scale is
PACKED-NUM2
GIVING
the greater of this.scale() and
PACKED-NUM3
val.scale()
BigDecimal subtract
Returns a BigDecimal whose value
SUBTRACT
PACKED-NUM1
(BigDecimal val)
is (this
val), and whose scale is
FROM
PACKED-NUM2
the greater of this.scale() and
GIVING
PACKED-NUM3
val.scale()
BigDecimal multiply
Returns a BigDecimal whose value
MULTIPLY
PACKED-NUM1
BY
(BigDecimal val)
is (this * val), and whose scale is
PACKED-NUM2
GIVING
the sum of this.scale() and val.scale()
PACKED-NUM3
BigDecimal divide
Returns a BigDecimal whose value
DIVIDE
PACKED-NUM1
BY
(BigDecimal val, int
is (this / val), and whose scale is
PACKED-NUM2
GIVING
roundingMode)
the same as this.scale(). Rounding
PACKED-NUM3
ROUNDED
behavior is controlled by the value
of roundingMode
BigDecimal divide
Returns a BigDecimal whose value
DIVIDE
PACKED-NUM1
BY
(BigDecimal val, int
is (this / val), and whose scale is as
PACKED-NUM2
GIVING
scale, int
specified by scale
PACKED-NUM3
ROUNDED
roundingMode)
Lint scale
Returns the scale of this BigDecimal
(BigDecimal val)
BigDecimal setScale
Returns a BigDecimal whose scale
MOVE
PACKED-NUM1
INTO
(int scale, int
is as specified. Truncated digits are
PACKED-NUM2
roundingMode)
evaluated based on the
roundingMode