API Overview API Index Package Overview Direct link to this page
JDK 1.6
  java.math. BigDecimal View Source
Author(s)
Josh Bloch
Mike Cowlishaw
Joseph D. Darcy
Since
Version
Serial
Hierarchy
 Object
      Number
          BigDecimal
Implements
 Comparable
Subclasses
Description
public class BigDecimal
  Immutable, arbitrary-precision signed decimal numbers.
Constructors
public BigDecimal (BigInteger val)
  Translates a BigInteger into a BigDecimal.
public BigDecimal (BigInteger unscaledVal, int scale)
  Translates a BigInteger unscaled value and an int scale into a BigDecimal.
public BigDecimal (BigInteger unscaledVal, int scale, MathContext mc)
  Translates a BigInteger unscaled value and an int scale into a BigDecimal, with rounding according to the context settings.
private BigDecimal (BigInteger intVal, long val, int scale)
Trusted internal constructor
public BigDecimal (BigInteger val, MathContext mc)
  Translates a BigInteger into a BigDecimal rounding according to the context settings.
public BigDecimal (char[] in)
  Translates a character array representation of a BigDecimal into a BigDecimal, accepting the same sequence of characters as the BigDecimal.BigDecimal(String) constructor.
public BigDecimal (char[] in, int offset, int len)
  Translates a character array representation of a BigDecimal into a BigDecimal, accepting the same sequence of characters as the BigDecimal.BigDecimal(String) constructor, while allowing a sub-array to be specified.
public BigDecimal (char[] in, int offset, int len, MathContext mc)
  Translates a character array representation of a BigDecimal into a BigDecimal, accepting the same sequence of characters as the BigDecimal.BigDecimal(String) constructor, while allowing a sub-array to be specified and with rounding according to the context settings.
public BigDecimal (char[] in, MathContext mc)
  Translates a character array representation of a BigDecimal into a BigDecimal, accepting the same sequence of characters as the BigDecimal.BigDecimal(String) constructor and with rounding according to the context settings.
public BigDecimal (double val)
  Translates a double into a BigDecimal which is the exact decimal representation of the double's binary floating-point value.
public BigDecimal (double val, MathContext mc)
  Translates a double into a BigDecimal, with rounding according to the context settings.
public BigDecimal (int val)
  Translates an int into a BigDecimal.
public BigDecimal (int val, MathContext mc)
  Translates an int into a BigDecimal, with rounding according to the context settings.
public BigDecimal (long val)
  Translates a long into a BigDecimal.
private BigDecimal (long val, int scale)
Trusted internal constructor
public BigDecimal (long val, MathContext mc)
  Translates a long into a BigDecimal, with rounding according to the context settings.
public BigDecimal (String val)
  Translates the string representation of a BigDecimal into a BigDecimal.
public BigDecimal (String val, MathContext mc)
  Translates the string representation of a BigDecimal into a BigDecimal, accepting the same strings as the BigDecimal.BigDecimal(String) constructor, with rounding according to the context settings.
Methods
Hide/Show inherited methods
public BigDecimal abs ()
  Returns a BigDecimal whose value is the absolute value of this BigDecimal, and whose scale is this.scale().
public BigDecimal abs (MathContext mc)
  Returns a BigDecimal whose value is the absolute value of this BigDecimal, with rounding according to the context settings.
public BigDecimal add (BigDecimal augend)
  Returns a BigDecimal whose value is (this + augend), and whose scale is max(this.scale(), augend.scale()).
public BigDecimal add (BigDecimal augend, MathContext mc)
  Returns a BigDecimal whose value is (this + augend), with rounding according to the context settings.
public byte byteValue () [Inherited From Number]
  Returns the value of the specified number as a byte.
public byte byteValueExact ()
  Converts this BigDecimal to a byte, checking for lost information.
public int compareTo (BigDecimal val)
  Compares this BigDecimal with the specified BigDecimal.
public BigDecimal divide (BigDecimal divisor)
  Returns a BigDecimal whose value is (this / divisor), and whose preferred scale is (this.scale() - divisor.scale()); if the exact quotient cannot be represented (because it has a non-terminating decimal expansion) an ArithmeticException is thrown.
public BigDecimal divide (BigDecimal divisor, int roundingMode)
  Returns a BigDecimal whose value is (this / divisor), and whose scale is this.scale().
public BigDecimal divide (BigDecimal divisor, int scale, int roundingMode)
  Returns a BigDecimal whose value is (this / divisor), and whose scale is as specified.
public BigDecimal divide (BigDecimal divisor, int scale, RoundingMode roundingMode)
  Returns a BigDecimal whose value is (this / divisor), and whose scale is as specified.
public BigDecimal divide (BigDecimal divisor, MathContext mc)
  Returns a BigDecimal whose value is (this / divisor), with rounding according to the context settings.
public BigDecimal divide (BigDecimal divisor, RoundingMode roundingMode)
  Returns a BigDecimal whose value is (this / divisor), and whose scale is this.scale().
public BigDecimal divideAndRemainder (BigDecimal divisor)
  Returns a two-element BigDecimal array containing the result of divideToIntegralValue followed by the result of remainder on the two operands.
public BigDecimal divideAndRemainder (BigDecimal divisor, MathContext mc)
  Returns a two-element BigDecimal array containing the result of divideToIntegralValue followed by the result of remainder on the two operands calculated with rounding according to the context settings.
public BigDecimal divideToIntegralValue (BigDecimal divisor)
  Returns a BigDecimal whose value is the integer part of the quotient (this / divisor) rounded down.
public BigDecimal divideToIntegralValue (BigDecimal divisor, MathContext mc)
  Returns a BigDecimal whose value is the integer part of (this / divisor).
public double doubleValue () [Specified in Number]
  Converts this BigDecimal to a double.
public boolean equals (Object x)
  Compares this BigDecimal with the specified Object for equality.
public float floatValue () [Specified in Number]
  Converts this BigDecimal to a float.
public int hashCode ()
  Returns the hash code for this BigDecimal.
public int intValue () [Specified in Number]
  Converts this BigDecimal to an int.
public int intValueExact ()
  Converts this BigDecimal to an int, checking for lost information.
public long longValue () [Specified in Number]
  Converts this BigDecimal to a long.
public long longValueExact ()
  Converts this BigDecimal to a long, checking for lost information.
public BigDecimal max (BigDecimal val)
  Returns the maximum of this BigDecimal and val.
public BigDecimal min (BigDecimal val)
  Returns the minimum of this BigDecimal and val.
public BigDecimal movePointLeft (int n)
  Returns a BigDecimal which is equivalent to this one with the decimal point moved n places to the left.
public BigDecimal movePointRight (int n)
  Returns a BigDecimal which is equivalent to this one with the decimal point moved n places to the right.
public BigDecimal multiply (BigDecimal multiplicand)
  Returns a BigDecimal whose value is (this × multiplicand), and whose scale is (this.scale() + multiplicand.scale()).
public BigDecimal multiply (BigDecimal multiplicand, MathContext mc)
  Returns a BigDecimal whose value is (this × multiplicand), with rounding according to the context settings.
public BigDecimal negate ()
  Returns a BigDecimal whose value is (-this), and whose scale is this.scale().
public BigDecimal negate (MathContext mc)
  Returns a BigDecimal whose value is (-this), with rounding according to the context settings.
public BigDecimal plus ()
  Returns a BigDecimal whose value is (+this), and whose scale is this.scale().
public BigDecimal plus (MathContext mc)
  Returns a BigDecimal whose value is (+this), with rounding according to the context settings.
public BigDecimal pow (int n)
  Returns a BigDecimal whose value is (thisn), The power is computed exactly, to unlimited precision.
public BigDecimal pow (int n, MathContext mc)
  Returns a BigDecimal whose value is (thisn).
public int precision ()
  Returns the precision of this BigDecimal.
public BigDecimal remainder (BigDecimal divisor)
  Returns a BigDecimal whose value is (this % divisor).
public BigDecimal remainder (BigDecimal divisor, MathContext mc)
  Returns a BigDecimal whose value is (this % divisor), with rounding according to the context settings.
public BigDecimal round (MathContext mc)
  Returns a BigDecimal rounded according to the MathContext settings.
public int scale ()
  Returns the scale of this BigDecimal.
public BigDecimal scaleByPowerOfTen (int n)
  Returns a BigDecimal whose numerical value is equal to (this * 10n).
public BigDecimal setScale (int newScale)
  Returns a BigDecimal whose scale is the specified value, and whose value is numerically equal to this BigDecimal's.
public BigDecimal setScale (int newScale, int roundingMode)
  Returns a BigDecimal whose scale is the specified value, and whose unscaled value is determined by multiplying or dividing this BigDecimal's unscaled value by the appropriate power of ten to maintain its overall value.
public BigDecimal setScale (int newScale, RoundingMode roundingMode)
  Returns a BigDecimal whose scale is the specified value, and whose unscaled value is determined by multiplying or dividing this BigDecimal's unscaled value by the appropriate power of ten to maintain its overall value.
public short shortValue () [Inherited From Number]
  Returns the value of the specified number as a short.
public short shortValueExact ()
  Converts this BigDecimal to a short, checking for lost information.
public int signum ()
  Returns the signum function of this BigDecimal.
public BigDecimal stripTrailingZeros ()
  Returns a BigDecimal which is numerically equal to this one but with any trailing zeros removed from the representation.
public BigDecimal subtract (BigDecimal subtrahend)
  Returns a BigDecimal whose value is (this - subtrahend), and whose scale is max(this.scale(), subtrahend.scale()).
public BigDecimal subtract (BigDecimal subtrahend, MathContext mc)
  Returns a BigDecimal whose value is (this - subtrahend), with rounding according to the context settings.
public BigInteger toBigInteger ()
  Converts this BigDecimal to a BigInteger.
public BigInteger toBigIntegerExact ()
  Converts this BigDecimal to a BigInteger, checking for lost information.
public String toEngineeringString ()
  Returns a string representation of this BigDecimal, using engineering notation if an exponent is needed.
public String toPlainString ()
  Returns a string representation of this BigDecimal without an exponent field.
public String toString ()
  Returns the string representation of this BigDecimal, using scientific notation if an exponent is needed.
public BigDecimal ulp ()
  Returns the size of an ulp, a unit in the last place, of this BigDecimal.
public BigInteger unscaledValue ()
  Returns a BigInteger whose value is the unscaled value of this BigDecimal.
publicstatic BigDecimal valueOf (double val)
  Translates a double into a BigDecimal, using the double's canonical string representation provided by the Double.toString(double) method.
publicstatic BigDecimal valueOf (long val)
  Translates a long value into a BigDecimal with a scale of zero.
publicstatic BigDecimal valueOf (long unscaledVal, int scale)
  Translates a long unscaled value and an int scale into a BigDecimal.
Fields
Hide/Show inherited fields
publicfinalstatic BigDecimal ONE
  The value 1, with a scale of 0.
publicfinalstatic int ROUND_CEILING = "2"
  Rounding mode to round towards positive infinity.
publicfinalstatic int ROUND_DOWN = "1"
  Rounding mode to round towards zero.
publicfinalstatic int ROUND_FLOOR = "3"
  Rounding mode to round towards negative infinity.
publicfinalstatic int ROUND_HALF_DOWN = "5"
  Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round down.
publicfinalstatic int ROUND_HALF_EVEN = "6"
  Rounding mode to round towards the "nearest neighbor" unless both neighbors are equidistant, in which case, round towards the even neighbor.
publicfinalstatic int ROUND_HALF_UP = "4"
  Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round up.
publicfinalstatic int ROUND_UNNECESSARY = "7"
  Rounding mode to assert that the requested operation has an exact result, hence no rounding is necessary.
publicfinalstatic int ROUND_UP = "0"
  Rounding mode to round away from zero.
publicfinalstatic BigDecimal TEN
  The value 10, with a scale of 0.
publicfinalstatic BigDecimal ZERO
  The value 0, with a scale of 0.
Nested Classes
Generated By: JavaOnTracks Doclet 0.1.4     ©Thibaut Colar