BigDecimal to String

In this chapter you will learn:

  1. How to Convert BigDecimal to String

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;
/*from   j av a2  s.c  o  m*/
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:

Next chapter...

What you will learn in the next chapter:

  1. Methods to move decimal point
Home » Java Tutorial » BigDecimal BigInteger

BigDecimal

    BigDecimal
    BigDecimal constants
    BigDecimal Rounding mode
    BigDecimal creation
    BigDecimal calculation
    BigDecimal convert
    BigDecimal Comparison
    BigDecimal to String
    BigDecimal decimal point
    BigDecimal precision
    BigDecimal format

BigInteger

    BigInteger class
    BigInteger creation
    BigInteger add, subtract, multiply and divide
    BigInteger power and modPow
    BigInteger conversion
    BigInteger to String
    BigInteger bit and,or,xor,test,flip,negate
    BigInteger bit shift left and right
    BigInteger prime value
    BigDecimal
    BigDecimal constants
    BigDecimal Rounding mode
    BigDecimal creation
    BigDecimal calculation
    BigDecimal convert
    BigDecimal Comparison
    BigDecimal to String
    BigDecimal decimal point
    BigDecimal precision
    BigDecimal format