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.
Asked
Active
Viewed 544 times
3

JanLeeYu
- 981
- 2
- 9
- 24
-
`1.00E-7` and `0.0000001` are numerically equal. Do you mean changing the `String` representation? You should also include the relevant code in your question. – Jonny Henly Mar 16 '16 at 04:03
-
Possible duplicate of [Converting exponential value in java to a number format](http://stackoverflow.com/questions/13563747/converting-exponential-value-in-java-to-a-number-format) – prasad Mar 16 '16 at 04:04
-
@prasad that question does have multiple answers, but none are accepted and each answer has a comment from OP saying the desired results were not achieved. Not saying it isn't a possible duplicate or that this question isn't a duplicate of another SO question. – Jonny Henly Mar 16 '16 at 04:11
3 Answers
3
Use BigDecimal#toPlainString()
, per the documentation:
toPlainString()
- Returns a string representation of thisBigDecimal
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
).

Jonny Henly
- 4,023
- 4
- 26
- 43
2
BigDecimal bigD = new BigDecimal("1.00E-7");
System.out.println(bigD.toPlainString());

Raghu K Nair
- 3,854
- 1
- 28
- 45
-
1Oh..yea my apologies yea the answer is not correct. I have not read the question clearly. – Raghu K Nair Mar 16 '16 at 04:20
-