0

Good Day,

I'm experiencing about E value from double field I get from my database. Is there any method on how I remove/convert the E from the field value to become double variable.

Example value I get from the database field value:

5.7377159E7

Dmitriy Popov
  • 2,150
  • 3
  • 25
  • 34
P. James
  • 415
  • 4
  • 15
  • How do you print/view and retrieve this value? Please share some code if possible. This question is pretty vague as it is right now – leonardkraemer Feb 26 '20 at 10:28
  • Does this help https://stackoverflow.com/questions/16098046/how-do-i-print-a-double-value-without-scientific-notation-using-java ? – matt freake Feb 26 '20 at 10:28
  • 2
    The linked-to question resolves the issue, but please be aware that you can't "remove E from a double". All you can do is *present* (a.k.a. format) the number in a different format. Doing that won't change anything about how the number is stored. – Joachim Sauer Feb 26 '20 at 10:31
  • 1
    Just to add to what Joachim said, you can't "remove E from a double" because double doesn't have E. Double is just a binary number. It is up to the formater to display that number with E or not. – Amongalen Feb 26 '20 at 10:37

1 Answers1

2

you can use a decimal formatter as shown below

               DecimalFormat df = new DecimalFormat("#");
                df.setMaximumFractionDigits(10);
                 System.out.print(df.format("your_var_with_E"));

you can set the max number of decimal places by setMaximumFractionDigits

Chiran K.
  • 406
  • 3
  • 16