Convert BigDecimal to String
String toEngineeringString()
- Using engineering notation if an exponent is needed.
String toPlainString()
- Without an exponent field.
String toString()
- Using scientific notation if an exponent is needed.
import java.math.BigDecimal;
public class Main {
public static void main(String[] args) {
BigDecimal first = new BigDecimal(100000f);
System.out.println(first.toEngineeringString());
System.out.println(first.toPlainString());
System.out.println(first.toString());
}
}
The output:
100000
100000
100000
Home
Java Book
Essential Classes
Java Book
Essential Classes
BigDecimal:
- BigDecimal class
- Constants for One, Ten and Zero
- Rounding mode
- Create BigDecimals
- Methods used to do calculation
- Convert BigDecimal to primitive data types
- Compare two BigDecimal
- Move decimal point
- Scale and precision
- Convert BigDecimal to String
- Remove the trailing zeros
- Convert double and long to BigDecimal
- Calculating Euler's number e with BigDecimal