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, 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 num)
public BigDecimal(BigInteger num, int scale) throws NumberFormatException
NumberFormatException
public BigDecimal(double num) throws NumberFormatException
NumberFormatException
public BigDecimal(String num) throws NumberFormatException
NumberFormatException
public 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
NumberFormatException
public 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)
Comparable
compareTo
in interface Comparable
public boolean equals(Object o)
Object
public int hashCode()
Object
public 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()
Object
public BigInteger toBigInteger()
public int intValue()
Number
Number
as an int
.public long longValue()
Number
Number
as a long
.public float floatValue()
Number
Number
as a float
.floatValue
in class Number
public double doubleValue()
Number
Number
as a float
.doubleValue
in class Number
public BigDecimal setScale(int scale) throws ArithmeticException
ArithmeticException
public 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)
ByteEncodable
encodeBytes
in interface ByteEncodable
dest
- The destination ByteArray, or null to determine the number of bytes needed to encode.public byte[] encodeBytes()
encodeBytes
in interface ByteEncodable
public byte[] toByteArray()
public static int compareEncoded(byte[] one, int oneOffset, int oneLen, byte[] two, int twoOffset, int twoLen)