Package org.gudy.bouncycastle.math.ec
Class SimpleBigDecimal
java.lang.Object
org.gudy.bouncycastle.math.ec.SimpleBigDecimal
Class representing a simple version of a big decimal. A
SimpleBigDecimal
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 SimpleBigDecimal
.
Unlike in BigDecimal
, the scale is not adjusted
automatically, but must be set manually. All SimpleBigDecimal
s
taking part in the same arithmetic operation must have equal scale. The
result of a multiplication of two SimpleBigDecimal
s returns a
SimpleBigDecimal
with double scale.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final BigInteger
private final int
private static final long
-
Constructor Summary
ConstructorsModifierConstructorDescriptionSimpleBigDecimal
(BigInteger bigInt, int scale) Constructor forSimpleBigDecimal
.private
SimpleBigDecimal
(SimpleBigDecimal limBigDec) -
Method Summary
Modifier and TypeMethodDescriptionadd
(BigInteger b) adjustScale
(int newScale) private void
int
compareTo
(BigInteger val) int
divide
(BigInteger b) double
boolean
float
floor()
static SimpleBigDecimal
getInstance
(BigInteger value, int scale) Returns aSimpleBigDecimal
representing the same numerical value asvalue
.int
getScale()
int
hashCode()
int
intValue()
long
negate()
round()
shiftLeft
(int n) toString()
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
bigInt
-
scale
private final int scale
-
-
Constructor Details
-
SimpleBigDecimal
Constructor forSimpleBigDecimal
. The value of the constructedSimpleBigDecimal
equalsbigInt / 2scale
.- Parameters:
bigInt
- ThebigInt
value parameter.scale
- The scale of the constructedSimpleBigDecimal
.
-
SimpleBigDecimal
-
-
Method Details
-
getInstance
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
-
adjustScale
-
add
-
add
-
negate
-
subtract
-
subtract
-
multiply
-
multiply
-
divide
-
divide
-
shiftLeft
-
compareTo
-
compareTo
-
floor
-
round
-
intValue
public int intValue() -
longValue
public long longValue() -
doubleValue
public double doubleValue() -
floatValue
public float floatValue() -
getScale
public int getScale() -
toString
-
equals
-
hashCode
public int hashCode()
-