kz.gamma.hardware.crypto.software.ec
Class SimpleBigDecimal

java.lang.Object
  extended by kz.gamma.hardware.crypto.software.ec.SimpleBigDecimal

 class SimpleBigDecimal
extends java.lang.Object

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 SimpleBigDecimals taking part in the same arithmetic operation must have equal scale. The result of a multiplication of two SimpleBigDecimals returns a SimpleBigDecimal with double scale.


Field Summary
private  java.math.BigInteger bigInt
           
private  int scale
           
private static long serialVersionUID
           
 
Constructor Summary
  SimpleBigDecimal(java.math.BigInteger bigInt, int scale)
          Constructor for SimpleBigDecimal.
private SimpleBigDecimal(SimpleBigDecimal limBigDec)
           
 
Method Summary
 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)
           
 boolean equals(java.lang.Object o)
           
 java.math.BigInteger floor()
           
static SimpleBigDecimal getInstance(java.math.BigInteger value, int scale)
          Returns a SimpleBigDecimal representing the same numerical value as value.
 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()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

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 for SimpleBigDecimal. The value of the constructed SimpleBigDecimal equals bigInt / 2scale.

Parameters:
bigInt - The bigInt value parameter.
scale - The scale of the constructed SimpleBigDecimal.

SimpleBigDecimal

private SimpleBigDecimal(SimpleBigDecimal limBigDec)
Method Detail

getInstance

public static SimpleBigDecimal getInstance(java.math.BigInteger value,
                                           int scale)
Returns a SimpleBigDecimal representing the same numerical value as value.

Parameters:
value - The value of the SimpleBigDecimal to be created.
scale - The scale of the SimpleBigDecimal 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()

getScale

public int getScale()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object


Copyright © 2013 Gamma Technologies. All Rights Reserved.