BigDecimal.BigDecimal

BigDecimal.BigDecimal

Class Overview | Class Members | This Package | All Packages

Syntax 1
public BigDecimal( String val ) throws NumberFormatException
Description
Constructs a BigDecimal from a string containing an optional minus sign followed by a sequence of zero or more decimal digits, optionally followed by a fraction, which consists of a decimal point followed by zero or more decimal digits. The string must contain at least one digit in the integer or fractional part. The scale of the resulting BigDecimal will be the number of digits to the right of the decimal point in the string, or 0 if the string contains no decimal point. The character-to-digit mapping is provided by Character.digit. Any extraneous characters (including whitespace) will result in a NumberFormatException.



Syntax 2
public BigDecimal( double val ) throws NumberFormatException
Description
Translates a double into a BigDecimal. The scale of the BigDecimal is the smallest value such that (10**scale * val) is an integer. A double whose value is -infinity, +infinity or NaN will result in a NumberFormatException.



Syntax 3
public BigDecimal( BigInteger val )
Description
Translates a BigInteger into a BigDecimal. The scale of the BigDecimal is zero.



Syntax 4
public BigDecimal( BigInteger val, int scale ) throws NumberFormatException
Description
Translates a BigInteger and a scale into a BigDecimal. The value of the BigDecimal is (BigInteger/10**scale). A negative scale will result in a NumberFormatException.