public class BigDecimal extends Number implements Comparable, ByteEncodable
Wherever possible, you should use this version of BigDecimal since it is compatible with Decimal - a mutable version of BigDecimal.
| 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 num) |
BigDecimal(BigInteger num,
int scale) |
BigDecimal(byte[] data) |
BigDecimal(byte[] data,
int offset,
int length)
Create a new BigDecimal from a byte array.
|
BigDecimal(double num) |
BigDecimal(String num) |
| Modifier and Type | Method and Description |
|---|---|
BigDecimal |
abs() |
BigDecimal |
add(BigDecimal val) |
static int |
compareEncoded(byte[] one,
int oneOffset,
int oneLen,
byte[] two,
int twoOffset,
int twoLen)
Compare two encoded versions of a BigDecimal as fast as possible.
|
int |
compareTo(BigDecimal val) |
int |
compareTo(Object val)
Compare this object with another.
|
BigDecimal |
divide(BigDecimal val,
int roundingMode) |
BigDecimal |
divide(BigDecimal val,
int newScale,
int roundingMode) |
double |
doubleValue()
Return the value of this
Number as a float. |
byte[] |
encodeBytes() |
int |
encodeBytes(ByteArray dest)
This requests the Object to encode itself as a stream of bytes which is appended
to the destination ByteArray.
|
boolean |
equals(Object o)
Returns if this object is considered equal to the other object.
|
float |
floatValue()
Return the value of this
Number as a float. |
int |
hashCode()
Returns a hashCode for the object.
|
int |
intValue()
Return the value of this
Number as an int. |
long |
longValue()
Return the value of this
Number as a long. |
BigDecimal |
max(BigDecimal val) |
BigDecimal |
min(BigDecimal val) |
BigDecimal |
movePointLeft(int n) |
BigDecimal |
movePointRight(int n) |
BigDecimal |
multiply(BigDecimal val) |
BigDecimal |
negate() |
int |
scale() |
BigDecimal |
setScale(int scale) |
BigDecimal |
setScale(int scale,
int roundingMode) |
int |
signum() |
BigDecimal |
subtract(BigDecimal val) |
BigInteger |
toBigInteger() |
byte[] |
toByteArray() |
static BigDecimal |
toEveBigDecimal(BigDecimal jbd)
Convert a java.math.BigDecimal into an eve.math.BigDecimal as effeciently as possible.
|
static BigDecimal |
toJavaBigDecimal(BigDecimal ebd)
Convert a BigDecimal into a java.math.BigDecimal as effeciently as possible.
|
String |
toString()
Return a String representation of this object.
|
CharArray |
toString(CharArray ca) |
BigInteger |
unscaledValue() |
static BigDecimal |
valueOf(long val) |
static BigDecimal |
valueOf(long val,
int scale) |
int |
write(byte[] data,
int offset)
Write the BigDecimal as a series of bytes, or find out how many bytes are needed
for storing the BigDecimal.
|
byteValue, shortValuepublic 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 num)
public BigDecimal(BigInteger num, int scale) throws NumberFormatException
NumberFormatExceptionpublic BigDecimal(double num)
throws NumberFormatException
NumberFormatExceptionpublic BigDecimal(String num) throws NumberFormatException
NumberFormatExceptionpublic BigDecimal(byte[] data,
int offset,
int length)
data - the data to read.offset - the start of the data.length - the number of bytes of encoded data.public BigDecimal(byte[] data)
public static BigDecimal valueOf(long val)
public static BigDecimal valueOf(long val, int scale) throws NumberFormatException
NumberFormatExceptionpublic static BigDecimal toEveBigDecimal(BigDecimal jbd)
jbd - the java.math.BigDecimal value.public static BigDecimal toJavaBigDecimal(BigDecimal ebd)
ebd - the BigDecimal value.public BigDecimal add(BigDecimal val)
public BigDecimal subtract(BigDecimal val)
public BigDecimal multiply(BigDecimal val)
public BigDecimal divide(BigDecimal val, int roundingMode) throws ArithmeticException, IllegalArgumentException
public BigDecimal divide(BigDecimal val, int newScale, int roundingMode) throws ArithmeticException, IllegalArgumentException
public int compareTo(BigDecimal val)
public int compareTo(Object val)
ComparablecompareTo in interface Comparablepublic boolean equals(Object o)
Objectpublic int hashCode()
Objectpublic BigDecimal max(BigDecimal val)
public BigDecimal min(BigDecimal val)
public BigDecimal movePointLeft(int n)
public BigDecimal movePointRight(int n)
public int signum()
public int scale()
public BigInteger unscaledValue()
public BigDecimal abs()
public BigDecimal negate()
public String toString()
Objectpublic BigInteger toBigInteger()
public int intValue()
NumberNumber as an int.public long longValue()
NumberNumber as a long.public float floatValue()
NumberNumber as a float.floatValue in class Numberpublic double doubleValue()
NumberNumber as a float.doubleValue in class Numberpublic BigDecimal setScale(int scale) throws ArithmeticException
ArithmeticExceptionpublic BigDecimal setScale(int scale, int roundingMode) throws ArithmeticException, IllegalArgumentException
public int write(byte[] data,
int offset)
data - The destination byte array or null to find out how many bytes are needed.offset - The offset in the byte array to write to.public int encodeBytes(ByteArray dest)
ByteEncodableencodeBytes in interface ByteEncodabledest - The destination ByteArray, or null to determine the number of bytes needed to encode.public byte[] encodeBytes()
encodeBytes in interface ByteEncodablepublic byte[] toByteArray()
public static int compareEncoded(byte[] one,
int oneOffset,
int oneLen,
byte[] two,
int twoOffset,
int twoLen)