java.math.BigDecimal
Immutable, arbitrary-precision signed decimal numbers. A BigDecimal consists of an arbitrary precision integer unscaled value and a 32-bit integer scale. If zero or positive, the scale is the number of digits to the right of the decimal point. If negative, the unscaled value of the number is multiplied by ten to the power of the negation of the scale.
The BigDecimal class provides operations for arithmetic, scale manipulation, rounding, comparison, hashing, and format conversion. The toString method provides a canonical representation of a BigDecimal.
Some of the Methods of StrictMath class.
scaleByPowerOfTen(int): It returns a BigDecimal whose numerical value is equal to(this * 10^n).
setScale(int): It returns a BigDecimal whose scale is the specified value, and whose value is numerically equal to this BigDecimal's.
setScale(int, RoundingMode): It 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.
shortValue(): It returns the value of the specified number as a short.
shortValueExact(): It converts this BigDecimal to a short, checking for lost information.
signum(): It returns the signum function of this BigDecimal.
sqrt(MathContext): It returns an approximation to the square root of this with rounding according to the context settings.
stripTrailingZeros(): It returns a BigDecimal which is numerically equal to this one but with any trailing zeros removed from the representation
subtract(BigDecimal): It returns a BigDecimal whose value is (this -subtrahend), and whose scale is max(this.scale(),subtrahend.scale()).
subtract(BigDecimal, MathContext): It returns a BigDecimal whose value is (this - subtrahend), with rounding according to the context settings.
Some constants of BigDecimal: Some constants of BigDecimal, BigDecimal.ONE, BigDecimal.ZERO and BigDecimal.TEN
toBigInteger(): It converts this BigDecimal to a BigInteger.
toBigIntegerExact(): It converts this BigDecimal to a BigInteger, checking for lost information. An exception is thrown if this BigDecimal has a nonzero fractional part.
toEngineeringString(): It returns a string representation of this BigDecimal, using engineering notation if an exponent is needed.
toPlainString(): It returns a string representation of this BigDecimal without an exponent field.
toString(): It returns the string representation of this BigDecimal, using scientific notation if an exponent is needed.
ulp(): It returns the size of an ulp, a unit in the last place, of this BigDecimal.
unscaledValue(): It returns a BigInteger whose value is the unscaled value of this BigDecimal. (Computes (this *10^this.scale()).)
BigDecimal.valueOf(long, int): It translates a long unscaled value and an int scale into a BigDecimal.
BigDecimal.valueOf(double): It translates a double into a BigDecimal, using the double's canonical string representation.
BigDecimal.valueOf(long): It translates a long value into a BigDecimalwith a scale of zero.
No comments:
Post a Comment