public class BigDecimal extends Object
BigDecimal is basically a
BigInteger with a few digits on the right of
the decimal point. The number of (binary) digits on the right of the decimal
point is called the scale of the BigDecimal.
Unlike in BigDecimal, the scale is not adjusted
automatically, but must be set manually. All BigDecimals
taking part in the same arithmetic operation must have equal scale. The
result of a multiplication of two BigDecimals returns a
BigDecimal with double scale.| Constructor and Description |
|---|
BigDecimal(BigInteger bigInt,
int scale)
Constructor for
BigDecimal. |
| Modifier and Type | Method and Description |
|---|---|
BigDecimal |
add(BigDecimal b) |
BigDecimal |
add(BigInteger b) |
BigDecimal |
adjustScale(int newScale) |
int |
compareTo(BigDecimal val) |
int |
compareTo(BigInteger val) |
BigDecimal |
divide(BigDecimal b) |
BigDecimal |
divide(BigInteger b) |
boolean |
equals(Object o)
Indicates whether some other object is "equal to" this one.
|
BigInteger |
floor() |
static BigDecimal |
getInstance(BigInteger value,
int scale)
Deprecated.
This method is not part of the JDK's
BigDecimal class and its presence is historical,
as the first implementation of Codename One's BigDecimal class was ported from BouncyCastle, which is different
than the JDK's BigDecimal class in that is optimizes binary arithmetic. The implementation of this method
is counter-intuitive since it performs a bitwise left shift on value before scaling it. Use BigDecimal(com.codename1.util.BigInteger, int)
instead if you just want to convert a BigInteger into a BigDecimal. Do not rely on this method
as it will be removed in a future version of Codename One.. |
int |
getScale() |
int |
hashCode()
Returns a hash code value for the object.
|
int |
intValue() |
long |
longValue() |
BigDecimal |
multiply(BigDecimal b) |
BigDecimal |
multiply(BigInteger b) |
BigDecimal |
negate() |
BigInteger |
round() |
BigDecimal |
shiftLeft(int n) |
BigDecimal |
subtract(BigDecimal b) |
BigDecimal |
subtract(BigInteger b) |
String |
toString()
Returns a string representation of the object.
|
public BigDecimal(BigInteger bigInt, int scale)
BigDecimal. The value of the
constructed BigDecimal equals bigInt /
10scale.bigInt - The bigInt value parameter.scale - The scale of the constructed BigDecimal.public static BigDecimal getInstance(BigInteger value, int scale)
BigDecimal class and its presence is historical,
as the first implementation of Codename One's BigDecimal class was ported from BouncyCastle, which is different
than the JDK's BigDecimal class in that is optimizes binary arithmetic. The implementation of this method
is counter-intuitive since it performs a bitwise left shift on value before scaling it. Use BigDecimal(com.codename1.util.BigInteger, int)
instead if you just want to convert a BigInteger into a BigDecimal. Do not rely on this method
as it will be removed in a future version of Codename One..BigDecimal with value value / 2scale / 10scalevalue - The value of the BigDecimal to be
created.scale - The scale of the BigDecimal to be
created.BigDecimal.public BigDecimal adjustScale(int newScale)
public BigDecimal add(BigDecimal b)
public BigDecimal add(BigInteger b)
public BigDecimal negate()
public BigDecimal subtract(BigDecimal b)
public BigDecimal subtract(BigInteger b)
public BigDecimal multiply(BigDecimal b)
public BigDecimal multiply(BigInteger b)
public BigDecimal divide(BigDecimal b)
public BigDecimal divide(BigInteger b)
public BigDecimal shiftLeft(int n)
public int compareTo(BigDecimal val)
public int compareTo(BigInteger val)
public BigInteger floor()
public BigInteger round()
public int intValue()
public long longValue()
public int getScale()
public String toString()
Objectpublic boolean equals(Object o)
Objectpublic int hashCode()
Object