Fields
Name | Description |
---|---|
ROUND_CEILING | If the BigDecimal is positive, behave as for ROUND_UP; if negative, behave as for ROUND_DOWN. |
ROUND_DOWN | Never increment the digit prior to a discarded fraction (i.e., truncate). |
ROUND_FLOOR | If the BigDecimal is positive, behave as for ROUND_DOWN; if negative behave as for ROUND_UP. |
ROUND_HALF_DOWN | Behave as for ROUND_UP if the discarded fraction is > .5; otherwise, behave as for ROUND_DOWN. |
ROUND_HALF_EVEN | Behave as for ROUND_HALF_UP if the digit to the left of the discarded fraction is odd; behave as for ROUND_HALF_DOWN if it's even. |
ROUND_HALF_UP | Behave as for ROUND_UP if the discarded fraction is >= .5; otherwise, behave as for ROUND_DOWN. |
ROUND_UNNECESSARY | This "pseudo-rounding-mode" is actually an assertion that the requested operation has an exact result, hence no rounding is necessary. |
ROUND_UP | Always increment the digit prior to a non-zero discarded fraction. |
Constructors
Name | Description |
---|---|
BigDecimal(BigInteger) | Translates a BigInteger into a BigDecimal. |
BigDecimal(BigInteger, int) | Translates a BigInteger and a scale into a BigDecimal. |
BigDecimal(double) | Translates a double into a BigDecimal. |
BigDecimal(String) | Constructs a BigDecimal from a string containing an optional minus sign followed by a sequence of zero or more decimal digits, optionally followed by a fraction, which consists of a decimal point followed by zero or more decimal digits. |
Methods
Name | Description |
---|---|
abs() | Returns a BigDecimal whose value is the absolute value of this number, and whose scale is this.scale(). |
add(BigDecimal) | Returns a BigDecimal whose value is (this + val), and whose scale is MAX(this.scale(), val.scale). |
compareTo(BigDecimal) | Returns -1, 0 or 1 as this number is less than, equal to, or greater than val. |
divide(BigDecimal, int) | Returns a BigDecimal whose value is (this / val), and whose scale is this.scale(). |
divide(BigDecimal, int, int) | Returns a BigDecimal whose value is (this / val), and whose scale is as specified. |
doubleValue() | Converts the number to a double. |
equals(Object) | Returns true iff x is a BigDecimal whose value is equal to this number. |
floatValue() | Converts this number to a float. |
hashCode() | Computes a hash code for this object. |
intValue() | Converts this number to an int. |
longValue() | Converts this number to a long. |
max(BigDecimal) | Returns the BigDecimal whose value is the greater of this and val. |
min(BigDecimal) | Returns the BigDecimal whose value is the lesser of this and val. |
movePointLeft(int) | Returns a BigDecimal which is equivalent to this one with the decimal point moved n places to the left. |
movePointRight(int) | Moves the decimal point the specified number of places to the right. |
multiply(BigDecimal) | Returns a BigDecimal whose value is (this * val), and whose scale is this.scale() + val.scale. |
negate() | Returns a BigDecimal whose value is -1 * this, and whose scale is this.scale(). |
scale() | Returns the scale of this number. |
setScale(int) | Returns a BigDecimal whose scale is the specified value, and whose value is exactly equal to this number's. |
setScale(int, int) | Returns a BigDecimal whose scale is the specified value, and whose integer value is determined by multiplying or dividing this BigDecimal's integer value by the appropriate power of ten to maintain the overall value. |
signum() | Returns the signum function of this number (i.e., -1, 0 or 1 as the value of this number is negative, zero or positive). |
subtract(BigDecimal) | Returns a BigDecimal whose value is (this - val), and whose scale is MAX(this.scale(), val.scale). |
toBigInteger() | Converts this number to a BigInteger. |
toString() | Returns the string representation of this number. |
valueOf(long) | Returns a BigDecimal with the given value and a scale of zero. |
valueOf(long, int) | Returns a BigDecimal with a value of (val/10**scale). |