Class BigDecimal

java.lang.Object
com.codename1.util.BigDecimal

public class BigDecimal extends java.lang.Object
Class representing a simple version of a big decimal. A 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 Details

    • BigDecimal

      public BigDecimal(BigInteger bigInt, int scale)

      Constructor for BigDecimal. The value of the constructed BigDecimal equals bigInt / 10scale.

      Parameters
      • bigInt: The bigInt value parameter.

      • scale: The scale of the constructed BigDecimal.

  • Method Details

    • getInstance

      public static BigDecimal getInstance(BigInteger value, int scale)

      Returns a BigDecimal with value value / 2scale / 10scale

      Parameters
      • value: @param value The value of the BigDecimal to be created.

      • scale: @param scale The scale of the BigDecimal to be created.

      Returns

      The such created BigDecimal.

      Deprecated
    • adjustScale

      public BigDecimal adjustScale(int newScale)
    • add

      public BigDecimal add(BigDecimal b)
    • add

      public BigDecimal add(BigInteger b)
    • negate

      public BigDecimal negate()
    • subtract

      public BigDecimal subtract(BigDecimal b)
    • subtract

      public BigDecimal subtract(BigInteger b)
    • multiply

      public BigDecimal multiply(BigDecimal b)
    • multiply

      public BigDecimal multiply(BigInteger b)
    • divide

      public BigDecimal divide(BigDecimal b)
    • divide

      public BigDecimal divide(BigInteger b)
    • shiftLeft

      public BigDecimal shiftLeft(int n)
    • compareTo

      public int compareTo(BigDecimal val)
    • compareTo

      public int compareTo(BigInteger val)
    • floor

      public BigInteger floor()
    • round

      public BigInteger round()
    • intValue

      public int intValue()
    • longValue

      public long longValue()
    • getScale

      public int getScale()
    • toString

      public 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