0

I have been working with big numbers (with more that 20 digits) and for that reason I use Double . The form I get the numbers is like this 8.653762536765E28. What I want to do is just display the first 2 decimal digits. I want it like 8.65E28.

I tried to find about formatting double values but I wan't able to do it. The result I was getting was 86537...12312.00 .

What do you thing is a good approach for this case? How can I manage only the digits in front of the E (the base) and not the whole number?

marduc812
  • 1,177
  • 17
  • 26

1 Answers1

1

I think this is what you want to achieve:

 double d = 8.653762536765E28;
 DecimalFormat df = new DecimalFormat("0.00E0");
 System.out.print(df.format(d));
mariuss
  • 1,177
  • 2
  • 14
  • 30