Class 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 Detail

      • 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.
    • 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.
      • 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 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