public class BigDecimal extends Number implements Comparable
Modifier and Type | Field and Description |
---|---|
static int |
ROUND_CEILING |
static int |
ROUND_DOWN |
static int |
ROUND_FLOOR |
static int |
ROUND_HALF_DOWN |
static int |
ROUND_HALF_EVEN |
static int |
ROUND_HALF_UP |
static int |
ROUND_UNNECESSARY |
static int |
ROUND_UP |
Constructor and Description |
---|
BigDecimal(BigInteger val)
Translates a BigInteger into a BigDecimal.
|
BigDecimal(BigInteger unscaledVal,
int scale)
Translates a BigInteger unscaled value and an int scale into a BigDecimal.
|
BigDecimal(double val)
Translates a double into a BigDecimal.
|
BigDecimal(String val)
Translates the String representation of a BigDecmal into a BigDecimal.
|
Modifier and Type | Method and Description |
---|---|
BigDecimal |
abs()
Returns a BigDecimal whose value is the absolute value of this BigDecimal, and whose scale is this.scale().
|
BigDecimal |
add(BigDecimal val)
Returns a BigDecimal whose value is (this + val), and whose scale is max(this.scale(), val.scale()).
|
int |
compareTo(BigDecimal val)
Compares this BigDecimal with the specified BigDecimal.
|
int |
compareTo(Object o)
Compares this BigDecimal with the specified Object.
|
BigDecimal |
divide(BigDecimal val,
int roundingMode)
Returns a BigDecimal whose value is (this / val), and whose scale is this.scale().
|
BigDecimal |
divide(BigDecimal val,
int scale,
int roundingMode)
Returns a BigDecimal whose value is (this / val), and whose scale is as specified.
|
double |
doubleValue()
Converts this BigDecimal to a double.
|
boolean |
equals(Object x)
Compares this BigDecimal with the specified Object for equality.
|
float |
floatValue()
Converts this BigDecimal to a float.
|
int |
hashCode()
Returns the hash code for this BigDecimal.
|
int |
intValue()
Converts this BigDecimal to an int.
|
long |
longValue()
Converts this BigDecimal to a long.
|
BigDecimal |
max(BigDecimal val)
Returns the maximum of this BigDecimal and val.
|
BigDecimal |
min(BigDecimal val)
Returns the minimum of this BigDecimal and val.
|
BigDecimal |
movePointLeft(int n)
Returns a BigDecimal which is equivalent to this one with the decimal point moved n places to the left.
|
BigDecimal |
movePointRight(int n)
Moves the decimal point the specified number of places to the right.
|
BigDecimal |
multiply(BigDecimal val)
Returns a BigDecimal whose value is (this * val), and whose scale is (this.scale() + val.scale()).
|
BigDecimal |
negate()
Returns a BigDecimal whose value is (-this), and whose scale is this.scale().
|
int |
scale()
Returns the scale of this BigDecimal.
|
BigDecimal |
setScale(int scale)
Returns a BigDecimal whose scale is the specified value, and whose value is numerically equal to this BigDecimal's.
|
BigDecimal |
setScale(int scale,
int roundingMode)
Returns a BigDecimal whose scale is the specified value, and whose unscaled value is determined by multiplying or dividing this BigDecimal's unscaled value by the appropriate power of ten to maintain its overall value.
|
int |
signum()
Returns the signum function of this BigDecimal.
|
BigDecimal |
subtract(BigDecimal val)
Returns a BigDecimal whose value is (this - val), and whose scale is max(this.scale(), val.scale()).
|
BigInteger |
toBigInteger()
Converts this BigDecimal to a BigInteger.
|
String |
toString()
Returns the string representation of this BigDecimal.
|
BigInteger |
unscaledValue()
Returns a BigInteger whose value is the unscaled value of this BigDecimal.
|
static BigDecimal |
valueOf(long val)
Translates a long value into a BigDecimal with a scale of zero.
|
static BigDecimal |
valueOf(long unscaledVal,
int scale)
Translates a long unscaled value and an int scale into a BigDecimal.
|
byteValue, shortValue
public static final int ROUND_UP
public static final int ROUND_DOWN
public static final int ROUND_CEILING
public static final int ROUND_FLOOR
public static final int ROUND_HALF_UP
public static final int ROUND_HALF_DOWN
public static final int ROUND_HALF_EVEN
public static final int ROUND_UNNECESSARY
public BigDecimal(BigInteger val)
public BigDecimal(BigInteger unscaledVal, int scale)
public BigDecimal(double val)
public BigDecimal(String val)
public BigDecimal abs()
public BigDecimal add(BigDecimal val)
public int compareTo(BigDecimal val)
public int compareTo(Object o)
compareTo
in interface Comparable
public BigDecimal divide(BigDecimal val, int roundingMode)
public BigDecimal divide(BigDecimal val, int scale, int roundingMode)
public double doubleValue()
doubleValue
in class Number
public boolean equals(Object x)
public float floatValue()
floatValue
in class Number
public int hashCode()
public int intValue()
public long longValue()
public BigDecimal max(BigDecimal val)
public BigDecimal min(BigDecimal val)
public BigDecimal movePointLeft(int n)
public BigDecimal movePointRight(int n)
public BigDecimal multiply(BigDecimal val)
public BigDecimal negate()
public int scale()
public BigDecimal setScale(int scale)
public BigDecimal setScale(int scale, int roundingMode)
public int signum()
public BigDecimal subtract(BigDecimal val)
public BigInteger toBigInteger()
public String toString()
public BigInteger unscaledValue()
public static BigDecimal valueOf(long val)
public static BigDecimal valueOf(long unscaledVal, int scale)