-3

How can one truncate 6.280369834735099E-16 to 000000000000000628 in Java?

eebbesen
  • 5,070
  • 8
  • 48
  • 70
Ahmad Ali
  • 1
  • 2

1 Answers1

-1

Have you tried this?

double d =  6.280369834735099E-16;

NumberFormat formatter = new DecimalFormat("#.###################");  

String f = formatter.format(d);  
jasc24
  • 28
  • 4
  • Well, first of all if you want to do it this way, you should import java.text, once you have done this, you're able to do it this way. I'm pretty sure what you're doing wrong is that you're not using the right format. In my example I only used a general case, but this is the correct way for your specific case. NumberFormat formatter = new DecimalFormat("#.###################"); I already tried it, and it works – jasc24 Apr 15 '15 at 18:39