

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
java.lang.Object  +edu.neu.ccs.XObject  +edu.neu.ccs.XNumber  +edu.neu.ccs.XBigDecimal
XBigDecimal
is an object wrapper for the
arbitrary precision BigDecimal
class, that
also provides
capabilities. Hence, unlike Stringable
BigDecimal
,
objects of this class are mutable.
The default value for this class is
the BigDecimal
representation of zero.
This class provides the operations of the class
BigDecimal
in two forms. Member methods
will mutate the object that is operated on but leave all
parameters unchanged and will return void
.
Static methods will create new objects and change no
parameters. In all cases, if an argument to an operation
is null
, it is treated as zero.
Unlike simpler Stringable
numeric types,
XBigDecimal
does not support the
evaluation of arithmetic expressions when parsing input
from String data. The reason for this is that division
normally requires a rounding mode and it would be quite
awkward to supply that mode interactively in the midst
of an expression.
Field Summary  
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 the "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 the "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. 
Fields inherited from class edu.neu.ccs.XObject 
changeAdapter, VALUE 
Constructor Summary  
XBigDecimal()
Constructs a wrapper for the default BigDecimal value of zero. 

XBigDecimal(BigDecimal b)
Constructs a wrapper for the given BigDecimal
value. 

XBigDecimal(double x)
Translates a double into an XBigDecimal . 

XBigDecimal(long x)
Translates a long x into
an XBigDecimal that is mathematically equal to
x . 

XBigDecimal(long x,
int scale)
Translates a long x and
a scale into an XBigDecimal that is
mathematically equal to x/10^{scale} . 

XBigDecimal(String s)
Constructs an XBigDecimal using the information
contained in the given string data. 

XBigDecimal(XBigDecimal b)
Constructs an XBigDecimal by copying the
internal value of the given XBigDecimal . 

XBigDecimal(XBigInteger x)
Translates an XBigInteger x into
an XBigDecimal that is mathematically equal to
x . 

XBigDecimal(XBigInteger x,
int scale)
Translates an XBigInteger x and
a scale into an XBigDecimal that is
mathematically equal to x/10^{scale} . 
Method Summary  
void 
abs()
Sets this to abs(this) . 
static XBigDecimal 
abs(XBigDecimal y)
Returns a new XBigDecimal whose value is the absolute
value of the given y. 
void 
add(XBigDecimal y)
Sets this to (this + y) . 
static XBigDecimal 
add(XBigDecimal x,
XBigDecimal y)
Returns a new XBigDecimal whose value is
x + y . 
byte 
byteValue()
Returns the value of this number as a byte value. 
int 
compareTo(Object o)
Compares this XBigDecimal with the specified
Object o. 
int 
compareTo(XBigDecimal y)
Compares this XBigDecimal with the specified
XBigDecimal y. 
void 
divide(XBigDecimal y,
int roundingMode)
Sets this to (this / y)
and maintains the scale as this.scale() . 
void 
divide(XBigDecimal y,
int scale,
int roundingMode)
Sets this to (this / y)
using the given scale for the quotient. 
static XBigDecimal 
divide(XBigDecimal x,
XBigDecimal y,
int roundingMode)
Returns a new XBigDecimal whose value is
x / y and whose scale is x.scale() . 
static XBigDecimal 
divide(XBigDecimal x,
XBigDecimal y,
int scale,
int roundingMode)
Returns a new XBigDecimal whose value is
x / y and whose scale is the given scale. 
double 
doubleValue()
Returns the value of this number as a double value. 
boolean 
equals(Object other)
Returns true if the given object is of type
XBigDecimal and its BigDecimal
value is equal to the BigDecimal value of
this XBigDecimal ; returns false
otherwise. 
float 
floatValue()
Returns the value of this number as a float value. 
void 
fromStringData(String data)
Sets the state of this XBigDecimal using the
information contained in the given string data. 
BigDecimal 
getValue()
Returns the BigDecimal value wrapped
by this object. 
int 
hashCode()
Returns the int hash code
of the wrapped BigDecimal value. 
int 
intValue()
Returns the value of this number as a int value. 
static boolean 
isRoundingMode(int roundingMode)
Returns true if the rounding mode is valid; otherwise false. 
long 
longValue()
Returns the value of this number as a long value. 
void 
max(XBigDecimal y)
Sets this to max(this, y) . 
static XBigDecimal 
max(XBigDecimal x,
XBigDecimal y)
Returns a new XBigDecimal whose value is
the maximum of the given x and y values. 
void 
min(XBigDecimal y)
Sets this to min(this, y) . 
static XBigDecimal 
min(XBigDecimal x,
XBigDecimal y)
Returns a new XBigDecimal whose value is
the minimum of the given x and y values. 
void 
movePointLeft(int n)
Sets this to an XBigDecimal that is equivalent
to this with the decimal point moved n places to the left. 
static XBigDecimal 
movePointLeft(XBigDecimal y,
int n)
Returns a new XBigDecimal that is equivalent to the given
y with the decimal point moved n places to the left. 
void 
movePointRight(int n)
Sets this to an XBigDecimal that is equivalent
to this with the decimal point moved n places to the right. 
static XBigDecimal 
movePointRight(XBigDecimal y,
int n)
Returns a new XBigDecimal that is equivalent to the given
y with the decimal point moved n places to the right. 
void 
multiply(XBigDecimal y)
Sets this to (this * y) . 
static XBigDecimal 
multiply(XBigDecimal x,
XBigDecimal y)
Returns a new XBigDecimal whose value is
x * y . 
void 
negate()
Sets this to (this) . 
static XBigDecimal 
negate(XBigDecimal y)
Returns a new XBigDecimal whose value is the negation
of the given y. 
int 
scale()
Returns the scale of this XBigDecimal . 
void 
setScale(int scale)
Sets this to a numerically equal value whose scale is
the given scale. 
void 
setScale(int scale,
int roundingMode)
Sets this to an XBigDecimal whose scale is
the given scale and whose unscaled value is determined by multiplying or
dividing the unscaled value of this by the appropriate power
of ten to maintain its overall value; if the scale is reduced by the
operation, the unscaled value must be divided (rather than multiplied),
and the value may be changed; in this case, the specified rounding mode
is applied to the division. 
static XBigDecimal 
setScale(XBigDecimal y,
int scale)
Returns a new XBigDecimal whose scale is the given scale
and whose value is numerically equal to the given y . 
static XBigDecimal 
setScale(XBigDecimal y,
int scale,
int roundingMode)
Returns a new XBigDecimal whose scale is the given scale
and whose unscaled value is determined by multiplying or dividing the
unscaled value of the given y by the appropriate power of
ten to maintain its overall value; if the scale is reduced by the
operation, the unscaled value must be divided (rather than multiplied),
and the value may be changed; in this case, the specified rounding mode
is applied to the division. 
void 
setValue(BigDecimal b)
Sets the value wrapped by this object to the given BigDecimal value. 
void 
setValue(double x)
Translates a double into an XBigDecimal
that is then set as the value of this . 
void 
setValue(long x)
Translates a long x into
an XBigDecimal that is mathematically equal to
x . 
void 
setValue(long x,
int scale)
Translates a long x and
a scale into an XBigDecimal that is
mathematically equal to x/10^{scale} . 
void 
setValue(String data)
Sets the state of this XBigDecimal using the
information contained in the given string data. 
void 
setValue(XBigDecimal b)
Sets the value wrapped by this object to the internal value of the given XBigDecimal value. 
void 
setValue(XBigInteger x)
Translates an XBigInteger x into
an XBigDecimal that is mathematically equal to
x . 
void 
setValue(XBigInteger x,
int scale)
Translates an XBigInteger x and
a scale into an XBigDecimal that is
mathematically equal to x/10^{scale} . 
short 
shortValue()
Returns the value of this number as a short value. 
int 
signum()
Returns 1, 0 or 1 as the value of this XBigDecimal
is negative, zero or positive. 
void 
subtract(XBigDecimal y)
Sets this to (this  y) . 
static XBigDecimal 
subtract(XBigDecimal x,
XBigDecimal y)
Returns a new XBigDecimal whose value is
x  y . 
static BigDecimal[] 
toPrimitiveArray(XBigDecimal[] x)
Returns an array of BigDecimal objects
copied from the given array
of XBigDecimal objects. 
String 
toString()
Returns the string representation of the wrapped BigDecimal value. 
String 
toStringData()
Returns a string encapsulation of this XBigDecimal
that contains the information needed to set the state of this
XBigDecimal at a later time. 
XBigInteger 
toUnscaledXBigInteger()
Returns an XBigInteger whose value is the
unscaled value of this XBigDecimal . 
static XBigDecimal[] 
toXArray(BigDecimal[] a)
Returns an array of XBigDecimal objects
initialized from the given array
of BigDecimal objects. 
XBigInteger 
toXBigInteger()
Converts this XBigDecimal to an
XBigInteger by truncation, that is, by
discarding the fractional part of the number. 
Methods inherited from class edu.neu.ccs.XObject 
addPropertyChangeListener, addPropertyChangeListener, formatErrorMessage, removePropertyChangeListener, removePropertyChangeListener, toStringArray 
Methods inherited from class java.lang.Object 
clone, finalize, getClass, notify, notifyAll, wait, wait, wait 
Field Detail 
public static final int ROUND_UP
Rounding mode to round away from zero.
Always increments the digit prior to a nonzero discarded fraction.
Note that this rounding mode never decreases the magnitude of the calculated value.
public static final int ROUND_DOWN
Rounding mode to round towards zero.
Never increments the digit prior to a discarded fraction (i.e., truncates).
Note that this rounding mode never increases the magnitude of the calculated value.
public static final int ROUND_CEILING
Rounding mode to round towards positive infinity.
If the number
is positive, behaves as for ROUND_UP
;
if negative, behaves as for ROUND_DOWN
.
Note that this rounding mode never decreases the calculated value.
public static final int ROUND_FLOOR
Rounding mode to round towards negative infinity.
If the number
is positive, behaves as for ROUND_DOWN
;
if negative, behaves as for ROUND_UP
.
Note that this rounding mode never increases the calculated value.
public static final int ROUND_HALF_UP
Rounding mode to round towards the "nearest neighbor" unless both neighbors are equidistant, in which case round up.
Behaves as for ROUND_UP
if the discarded fraction is
>= .5; otherwise, behaves as for ROUND_DOWN
.
Note that this is the rounding mode that most of us were taught in grade school.
public static final int ROUND_HALF_DOWN
Rounding mode to round towards the "nearest neighbor" unless both neighbors are equidistant, in which case round down.
Behaves as for ROUND_UP
if the discarded fraction is
> .5; otherwise, behaves as for ROUND_DOWN
.
public static final 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.
Behaves as for ROUND_HALF_UP
if the digit to the left
of the discarded fraction is odd;
behaves as for ROUND_HALF_DOWN
if it's even.
Note that this is the rounding mode that minimizes cumulative error when applied repeatedly over a sequence of calculations.
public static final int ROUND_UNNECESSARY
Rounding mode to assert that the requested operation has an exact result, hence no rounding is necessary.
If this rounding mode is specified on an operation that yields an
inexact result, an ArithmeticException
is thrown.
Constructor Detail 
public XBigDecimal()
Constructs a wrapper for the default
BigDecimal
value of zero.
public XBigDecimal(BigDecimal b)
Constructs a wrapper for the given BigDecimal
value.
If the given value is null
, the wrapped value
is set to zero.
b
 the value to be wrappedpublic XBigDecimal(XBigDecimal b)
Constructs an XBigDecimal
by copying the
internal value of the given XBigDecimal
.
If the given value is null
, the wrapped value
is set to zero.
b
 the value to be copiedpublic XBigDecimal(String s) throws ParseException
Constructs an XBigDecimal
using the information
contained in the given string data.
Makes use of the parsing capabilities of the method
fromStringData(String)
.
s
 a string representation of the desired value
ParseException
 if the string is null
or malformedpublic XBigDecimal(XBigInteger x)
Translates an XBigInteger
x
into
an XBigDecimal
that is mathematically equal to
x
.
x
 the XBigInteger
used to set this valuepublic XBigDecimal(XBigInteger x, int scale)
Translates an XBigInteger
x
and
a scale
into an XBigDecimal
that is
mathematically equal to x/10^{scale}
.
x
 the XBigInteger
used to set this valuescale
 the poweroften scale factor which must be >= 0
NumberFormatException
 if scale is negativepublic XBigDecimal(long x)
Translates a long
x
into
an XBigDecimal
that is mathematically equal to
x
.
x
 the long
used to set this valuepublic XBigDecimal(long x, int scale)
Translates a long
x
and
a scale
into an XBigDecimal
that is
mathematically equal to x/10^{scale}
.
x
 the long
used to set this valuescale
 the poweroften scale factor which must be >= 0
NumberFormatException
 if scale is negativepublic XBigDecimal(double x)
Translates a double
into an XBigDecimal
.
The scale of the XBigDecimal
is the smallest value
such that (10^{scale}*x) is an integer.
Note: The results of this constructor can be somewhat unpredictable.
One might assume that new XBigDecimal(.1)
is exactly equal
to .1
, but it is actually equal to:
.1000000000000000055511151231257827021181583404541015625
This is so because .1
cannot be represented exactly as
a double (or, for that matter, as a binary fraction of any finite length).
Thus, the long value that is being passed in to the constructor is not
exactly equal to .1
, appearances notwithstanding.
The (String) constructor, on the other hand, is perfectly predictable:
new XBigDecimal(".1")
is exactly equal to .1
,
as one would expect. Therefore, it is generally recommended that the
XBigDecimal(String)
constructor be used in preference to
this one.
An alternate constructor option that is also precise is
new XBigDecimal(x,scale)
where x
is either
long
or XBigInteger
.
The only disadvantage of this option is that one must manually count the
correct number of decimal digits (scale) that must be used.
x
 the double
used to set this valueMethod Detail 
public void fromStringData(String data) throws ParseException
Sets the state of this XBigDecimal
using the
information contained in the given string data.
Utilizes the BigDecimal
constructor
BigDecimal(String)
to create the new internal
wrapped value. See the documentation of this constructor
for the details concerning the valid format in which this
decimal data may be supplied.
If the BigDecimal
constructor throws a
NumberFormatException
, this exception is
rethrown as a ParseException
.
If the given data is null
, also throws
a ParseException
.
Fires property change: VALUE.
fromStringData
in interface Stringable
fromStringData
in class XObject
data
 a string representation of the desired value
ParseException
 as explained aboveStringable.toStringData()
public String toStringData()
Returns a string encapsulation of this XBigDecimal
that contains the information needed to set the state of this
XBigDecimal
at a later time.
Identical to toString
.
toStringData
in interface Stringable
toStringData
in class XObject
Stringable.fromStringData(String)
public String toString()
Returns the string representation of the wrapped
BigDecimal
value.
The digittocharacter mapping provided by
Character.forDigit(int, int)
is used. A leading minus
sign is used to indicate sign and the number of digits to the
right of the decimal point is used to indicate scale.
This representation is compatible with the (String) constructor.
toString
in class Object
public boolean equals(Object other)
true
if the given object is of type
XBigDecimal
and its BigDecimal
value is equal to the BigDecimal
value of
this XBigDecimal
; returns false
otherwise.
equals
in class Object
public int hashCode()
int
hash code
of the wrapped BigDecimal
value.
hashCode
in class Object
public void setValue(BigDecimal b)
Sets the value wrapped by this object to the given
BigDecimal
value.
If the given value is null
, the internal
value is set to zero.
Fires property change: VALUE.
b
 the value to be wrappedpublic final void setValue(XBigDecimal b)
Sets the value wrapped by this object to the internal
value of the given XBigDecimal
value.
If the given input is null
, the internal
value is set to zero.
Fires property change: VALUE.
b
 the value to be copiedpublic final void setValue(String data) throws ParseException
Sets the state of this XBigDecimal
using the
information contained in the given string data.
Makes use of the parsing capabilities of the method
fromStringData(String)
.
Fires property change: VALUE.
data
 a string representation of the desired value
ParseException
 if data is null
or malformedpublic void setValue(XBigInteger x)
Translates an XBigInteger
x
into
an XBigDecimal
that is mathematically equal to
x
.
Fires property change: VALUE.
x
 the XBigInteger
used to set this valuepublic void setValue(XBigInteger x, int scale)
Translates an XBigInteger
x
and
a scale
into an XBigDecimal
that is
mathematically equal to x/10^{scale}
.
Fires property change: VALUE.
x
 the XBigInteger
used to set this valuescale
 the poweroften scale factor which must be >= 0
NumberFormatException
 if scale is negativepublic void setValue(long x)
Translates a long
x
into
an XBigDecimal
that is mathematically equal to
x
.
Uses BigDecimal.valueOf(long)
internally.
Fires property change: VALUE.
x
 the long
used to set this valuepublic void setValue(long x, int scale)
Translates a long
x
and
a scale
into an XBigDecimal
that is
mathematically equal to x/10^{scale}
.
Uses BigDecimal.valueOf(long, int)
internally.
Fires property change: VALUE.
x
 the long
used to set this valuescale
 the poweroften scale factor which must be >= 0
NumberFormatException
 if scale is negativepublic void setValue(double x)
Translates a double
into an XBigDecimal
that is then set as the value of this
.
The scale of the XBigDecimal
is the smallest value
such that (10^{scale}*x) is an integer.
Note: The result set via this method can be somewhat unpredictable.
One might assume that the result of setValue(.1)
is exactly
equal to .1
, but it is actually equal to:
.1000000000000000055511151231257827021181583404541015625
This is so because .1
cannot be represented exactly as
a double (or, for that matter, as a binary fraction of any finite length).
Thus, the long value that is being passed in to the inner constructor is
not exactly equal to .1
, appearances notwithstanding.
The setValue(String)
method, on the other hand, is perfectly
predictable: the result of setValue(".1")
is exactly equal to
.1
, as one would expect. Therefore, it is generally recommended
that the setValue(String)
method be used in preference to this
one.
An alternate option that is also precise is setValue(x,scale)
where x
is either long
or XBigInteger
.
The only disadvantage of this option is that one must manually count the
correct number of decimal digits (scale) that must be used.
Fires property change: VALUE.
x
 the double
used to set this valuepublic BigDecimal getValue()
Returns the BigDecimal
value wrapped
by this object.
public byte byteValue()
XNumber
byte
value.
byteValue
in class XNumber
public short shortValue()
XNumber
short
value.
shortValue
in class XNumber
public int intValue()
XNumber
int
value.
intValue
in class XNumber
public long longValue()
XNumber
long
value.
longValue
in class XNumber
public float floatValue()
XNumber
float
value.
floatValue
in class XNumber
public double doubleValue()
XNumber
double
value.
doubleValue
in class XNumber
public final int signum()
Returns 1, 0 or 1 as the value of this XBigDecimal
is negative, zero or positive.
public final int scale()
Returns the scale of this XBigDecimal
.
The scale is the number of digits to the right of the decimal point.
public final void setScale(int scale)
Sets this
to a numerically equal value whose scale is
the given scale.
Throws ArithmeticException
if:
scale
 the poweroften scale factor which must be >= 0
ArithmeticException
 as explained abovepublic static XBigDecimal setScale(XBigDecimal y, int scale)
Returns a new XBigDecimal
whose scale is the given scale
and whose value is numerically equal to the given y
.
Throws ArithmeticException
if:
y
 the explicit argumentscale
 the poweroften scale factor which must be >= 0
ArithmeticException
 as explained abovepublic final void setScale(int scale, int roundingMode)
Sets this
to an XBigDecimal
whose scale is
the given scale and whose unscaled value is determined by multiplying or
dividing the unscaled value of this
by the appropriate power
of ten to maintain its overall value; if the scale is reduced by the
operation, the unscaled value must be divided (rather than multiplied),
and the value may be changed; in this case, the specified rounding mode
is applied to the division.
Throws ArithmeticException
if:
ROUND_UNNECESSARY
and the given scale
is insufficient to represent the result of the division exactlyThrows IllegalArgumentException
if the
rounding mode is not a valid rounding mode.
scale
 the poweroften scale factor which must be >= 0roundingMode
 rounding mode to apply
ArithmeticException
 as explained above
IllegalArgumentException
 as explained abovepublic static XBigDecimal setScale(XBigDecimal y, int scale, int roundingMode)
Returns a new XBigDecimal
whose scale is the given scale
and whose unscaled value is determined by multiplying or dividing the
unscaled value of the given y
by the appropriate power of
ten to maintain its overall value; if the scale is reduced by the
operation, the unscaled value must be divided (rather than multiplied),
and the value may be changed; in this case, the specified rounding mode
is applied to the division.
Throws ArithmeticException
if:
ROUND_UNNECESSARY
and the given scale
is insufficient to represent the result of the division exactlyThrows IllegalArgumentException
if the
rounding mode is not a valid rounding mode.
y
 the explicit argumentscale
 the poweroften scale factor which must be >= 0roundingMode
 rounding mode to apply
ArithmeticException
 as explained above
IllegalArgumentException
 as explained abovepublic final void movePointLeft(int n)
Sets this
to an XBigDecimal
that is equivalent
to this
with the decimal point moved n places to the left.
The new value is this*10^{n}
.
The new scale is max(this.scale()+n,0)
.
n
 number of places to move the decimal point to the leftpublic static XBigDecimal movePointLeft(XBigDecimal y, int n)
Returns a new XBigDecimal
that is equivalent to the given
y
with the decimal point moved n places to the left.
The new value is y*10^{n}
.
The new scale is max(y.scale()+n,0)
.
y
 the explicit argumentn
 number of places to move the decimal point to the leftpublic final void movePointRight(int n)
Sets this
to an XBigDecimal
that is equivalent
to this
with the decimal point moved n places to the right.
The new value is this*10^{n}
.
The new scale is max(this.scale()n,0)
.
n
 number of places to move the decimal point to the rightpublic static XBigDecimal movePointRight(XBigDecimal y, int n)
Returns a new XBigDecimal
that is equivalent to the given
y
with the decimal point moved n places to the right.
The new value is y*10^{n}
.
The new scale is max(y.scale()n,0)
.
y
 the explicit argumentn
 number of places to move the decimal point to the rightpublic final XBigInteger toUnscaledXBigInteger()
Returns an XBigInteger
whose value is the
unscaled value of this XBigDecimal
.
Computes (this*10^{this.scale()})
.
If b=this.toUnscaledXBigInteger()
and
s=this.scale()
, then the method call
this.setValue(b,s)
will replace the
wrapped BigDecimal
with one of equal
value.
In particular, toUnscaledXBigInteger()
retains
all decimal digit information in this XBigDecimal
.
Uses BigDecimal.unscaledValue()
internally.
public final XBigInteger toXBigInteger()
Converts this XBigDecimal
to an
XBigInteger
by truncation, that is, by
discarding the fractional part of the number.
This conversion is analogous to a narrowing primitive
conversion from double
to long
as defined in the Java Language Specification.
Uses BigDecimal.toBigInteger()
internally.
public final void abs()
Sets this
to abs(this)
.
Fires property change: VALUE.
public static XBigDecimal abs(XBigDecimal y)
Returns a new XBigDecimal
whose value is the absolute
value of the given y.
y
 the explicit argumentpublic final void negate()
Sets this
to (this)
.
Fires property change: VALUE.
public static XBigDecimal negate(XBigDecimal y)
Returns a new XBigDecimal
whose value is the negation
of the given y.
y
 the explicit argumentpublic final void max(XBigDecimal y)
Sets this
to max(this, y)
.
Fires property change: VALUE.
y
 the explicit argumentpublic static XBigDecimal max(XBigDecimal x, XBigDecimal y)
Returns a new XBigDecimal
whose value is
the maximum of the given x and y values.
x
 the LHS argumenty
 the RHS argumentpublic final void min(XBigDecimal y)
Sets this
to min(this, y)
.
Fires property change: VALUE.
y
 the explicit argumentpublic static XBigDecimal min(XBigDecimal x, XBigDecimal y)
Returns a new XBigDecimal
whose value is
the minimum of the given x and y values.
x
 the LHS argumenty
 the RHS argumentpublic final void add(XBigDecimal y)
Sets this
to (this + y)
.
Fires property change: VALUE.
y
 the explicit argumentpublic static XBigDecimal add(XBigDecimal x, XBigDecimal y)
Returns a new XBigDecimal
whose value is
x + y
.
x
 the LHS argumenty
 the RHS argumentpublic final void subtract(XBigDecimal y)
Sets this
to (this  y)
.
Fires property change: VALUE.
y
 the explicit argumentpublic static XBigDecimal subtract(XBigDecimal x, XBigDecimal y)
Returns a new XBigDecimal
whose value is
x  y
.
x
 the LHS argumenty
 the RHS argumentpublic final void multiply(XBigDecimal y)
Sets this
to (this * y)
.
Fires property change: VALUE.
y
 the explicit argumentpublic static XBigDecimal multiply(XBigDecimal x, XBigDecimal y)
Returns a new XBigDecimal
whose value is
x * y
.
x
 the LHS argumenty
 the RHS argumentpublic final void divide(XBigDecimal y, int roundingMode)
Sets this
to (this / y)
and maintains the scale as this.scale()
.
If rounding must be performed to generate a result with the specified scale, the rounding mode is applied.
Throws ArithmeticException
if:
ROUND_UNNECESSARY
and this.scale()
is insufficient to
represent the result of the division exactlyThrows IllegalArgumentException
if the
rounding mode is not a valid rounding mode.
Fires property change: VALUE.
y
 the explicit argumentroundingMode
 rounding mode to apply
ArithmeticException
 as explained above
IllegalArgumentException
 as explained abovepublic static XBigDecimal divide(XBigDecimal x, XBigDecimal y, int roundingMode)
Returns a new XBigDecimal
whose value is
x / y
and whose scale is x.scale()
.
If rounding must be performed to generate a result with the specified scale, the rounding mode is applied.
Throws ArithmeticException
if:
ROUND_UNNECESSARY
and x.scale()
is insufficient to
represent the result of the division exactlyThrows IllegalArgumentException
if the
rounding mode is not a valid rounding mode.
x
 the LHS argumenty
 the RHS argumentroundingMode
 rounding mode to apply
ArithmeticException
 as explained above
IllegalArgumentException
 as explained abovepublic final void divide(XBigDecimal y, int scale, int roundingMode)
Sets this
to (this / y)
using the given scale for the quotient.
If rounding must be performed to generate a result with the specified scale, the rounding mode is applied.
Throws ArithmeticException
if:
ROUND_UNNECESSARY
and the given scale is insufficient to
represent the result of the division exactlyThrows IllegalArgumentException
if the
rounding mode is not a valid rounding mode.
Fires property change: VALUE.
y
 the explicit argumentscale
 the scale of the quotient which must be >= 0roundingMode
 rounding mode to apply
ArithmeticException
 as explained above
IllegalArgumentException
 as explained abovepublic static XBigDecimal divide(XBigDecimal x, XBigDecimal y, int scale, int roundingMode)
Returns a new XBigDecimal
whose value is
x / y
and whose scale is the given scale.
If rounding must be performed to generate a result with the specified scale, the rounding mode is applied.
Throws ArithmeticException
if:
ROUND_UNNECESSARY
and the given scale is insufficient to
represent the result of the division exactlyThrows IllegalArgumentException
if the
rounding mode is not a valid rounding mode.
x
 the LHS argumenty
 the RHS argumentscale
 the scale of the quotient which must be >= 0roundingMode
 rounding mode to apply
ArithmeticException
 as explained above
IllegalArgumentException
 as explained abovepublic static boolean isRoundingMode(int roundingMode)
Returns true if the rounding mode is valid; otherwise false.
roundingMode
 the proposed rounding modepublic final int compareTo(XBigDecimal y)
Compares this XBigDecimal
with the specified
XBigDecimal
y.
This method is provided in preference to individual methods for each of the six boolean comparison operators:
==, !=, <, <=, >, >=The suggested idiom for performing these comparisons is:
(x.compareTo(y) <op> 0)
where <op>
is one of the six comparison
operators.
Throws NullPointerException
if the given object
y is null
. Since this method is not specified in
the interface Comparable
, we throw the natural
exception rather than ClassCastException
which
is required in the more generic compareTo(Object)
method.
y
 the explicit argument
NullPointerException
 if y is null
public final int compareTo(Object o)
Compares this XBigDecimal
with the specified
Object
o.
This method is provided in preference to individual methods for each of the six boolean comparison operators:
==, !=, <, <=, >, >=The suggested idiom for performing these comparisons is:
(x.compareTo(y) <op> 0)
where <op>
is one of the six comparison
operators.
Throws ClassCastException
if the given object is
null
or is not of type XBigDecimal
.
This is consistent with the specification of the interface
Comparable
which this method implements.
o
 the Object
to compare
ClassCastException
 if o is null
or not of
type XBigDecimal
public static BigDecimal[] toPrimitiveArray(XBigDecimal[] x)
BigDecimal
objects
copied from the given array
of XBigDecimal
objects.
x
 an array of XBigDecimal
s
BigDecimal
objectspublic static XBigDecimal[] toXArray(BigDecimal[] a)
XBigDecimal
objects
initialized from the given array
of BigDecimal
objects.
a
 an array of BigDecimal
s
XBigDecimal
objects


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