Package org.gudy.bouncycastle.math.ec
Class SimpleBigDecimal
- java.lang.Object
-
- org.gudy.bouncycastle.math.ec.SimpleBigDecimal
-
class SimpleBigDecimal extends java.lang.Object
Class representing a simple version of a big decimal. ASimpleBigDecimal
is basically aBigInteger
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 thescale
of theSimpleBigDecimal
. Unlike inBigDecimal
, the scale is not adjusted automatically, but must be set manually. AllSimpleBigDecimal
s taking part in the same arithmetic operation must have equal scale. The result of a multiplication of twoSimpleBigDecimal
s returns aSimpleBigDecimal
with double scale.
-
-
Field Summary
Fields Modifier and Type Field Description private java.math.BigInteger
bigInt
private int
scale
private static long
serialVersionUID
-
Constructor Summary
Constructors Modifier Constructor Description SimpleBigDecimal(java.math.BigInteger bigInt, int scale)
Constructor forSimpleBigDecimal
.private
SimpleBigDecimal(SimpleBigDecimal limBigDec)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SimpleBigDecimal
add(java.math.BigInteger b)
SimpleBigDecimal
add(SimpleBigDecimal b)
SimpleBigDecimal
adjustScale(int newScale)
private void
checkScale(SimpleBigDecimal b)
int
compareTo(java.math.BigInteger val)
int
compareTo(SimpleBigDecimal val)
SimpleBigDecimal
divide(java.math.BigInteger b)
SimpleBigDecimal
divide(SimpleBigDecimal b)
double
doubleValue()
boolean
equals(java.lang.Object o)
float
floatValue()
java.math.BigInteger
floor()
static SimpleBigDecimal
getInstance(java.math.BigInteger value, int scale)
Returns aSimpleBigDecimal
representing the same numerical value asvalue
.int
getScale()
int
hashCode()
int
intValue()
long
longValue()
SimpleBigDecimal
multiply(java.math.BigInteger b)
SimpleBigDecimal
multiply(SimpleBigDecimal b)
SimpleBigDecimal
negate()
java.math.BigInteger
round()
SimpleBigDecimal
shiftLeft(int n)
SimpleBigDecimal
subtract(java.math.BigInteger b)
SimpleBigDecimal
subtract(SimpleBigDecimal b)
java.lang.String
toString()
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
bigInt
private final java.math.BigInteger bigInt
-
scale
private final int scale
-
-
Constructor Detail
-
SimpleBigDecimal
public SimpleBigDecimal(java.math.BigInteger bigInt, int scale)
Constructor forSimpleBigDecimal
. The value of the constructedSimpleBigDecimal
equalsbigInt / 2scale
.- Parameters:
bigInt
- ThebigInt
value parameter.scale
- The scale of the constructedSimpleBigDecimal
.
-
SimpleBigDecimal
private SimpleBigDecimal(SimpleBigDecimal limBigDec)
-
-
Method Detail
-
getInstance
public static SimpleBigDecimal getInstance(java.math.BigInteger value, int scale)
Returns aSimpleBigDecimal
representing the same numerical value asvalue
.- Parameters:
value
- The value of theSimpleBigDecimal
to be created.scale
- The scale of theSimpleBigDecimal
to be created.- Returns:
- The such created
SimpleBigDecimal
.
-
checkScale
private void checkScale(SimpleBigDecimal b)
-
adjustScale
public SimpleBigDecimal adjustScale(int newScale)
-
add
public SimpleBigDecimal add(SimpleBigDecimal b)
-
add
public SimpleBigDecimal add(java.math.BigInteger b)
-
negate
public SimpleBigDecimal negate()
-
subtract
public SimpleBigDecimal subtract(SimpleBigDecimal b)
-
subtract
public SimpleBigDecimal subtract(java.math.BigInteger b)
-
multiply
public SimpleBigDecimal multiply(SimpleBigDecimal b)
-
multiply
public SimpleBigDecimal multiply(java.math.BigInteger b)
-
divide
public SimpleBigDecimal divide(SimpleBigDecimal b)
-
divide
public SimpleBigDecimal divide(java.math.BigInteger b)
-
shiftLeft
public SimpleBigDecimal shiftLeft(int n)
-
compareTo
public int compareTo(SimpleBigDecimal val)
-
compareTo
public int compareTo(java.math.BigInteger val)
-
floor
public java.math.BigInteger floor()
-
round
public java.math.BigInteger round()
-
intValue
public int intValue()
-
longValue
public long longValue()
-
doubleValue
public double doubleValue()
-
floatValue
public float floatValue()
-
getScale
public int getScale()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-