JanLeeYu
JanLeeYu

Reputation: 1001

Exponents in java

Are there any built in java methods where I can convert this "1.00E-7" to "0.0000001"? I am using BigDecimal as datatype by the way. I am really stuck in here. any help would be appreciated.

Upvotes: 3

Views: 610

Answers (3)

Jonny Henly
Jonny Henly

Reputation: 4213

Use BigDecimal#toPlainString(), per the documentation:

toPlainString() - Returns a string representation of this BigDecimal without an exponent field.


BigDecimal's documentation lists three to*String() methods: The regular toString() method uses scientific notation (1.00E-7), while toEngineeringString() uses engineering notation (100E-9) and toPlainString() uses no notation (0.000000100).

Upvotes: 3

Fred
Fred

Reputation: 43

Use BigDecimal#toPlainString()

Upvotes: 1

Raghu K Nair
Raghu K Nair

Reputation: 3932

    BigDecimal bigD = new BigDecimal("1.00E-7"); 
    System.out.println(bigD.toPlainString());

Upvotes: 2

Related Questions