Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java and decimals E numbers

Tags:

java

Java comes up with numbers like 9.870699812169277E-4

How should I interpret it? Is there a way to parse it in Java and display without that E?

like image 912
Andrew Avatar asked Dec 26 '11 21:12

Andrew


1 Answers

You can use NumberFormat.

Code

// you can format to any output you want
NumberFormat formatter = new DecimalFormat("0.00000000000");
String string = formatter.format(9.870699812169277E-4);
System.out.println(string);

Result

0.00098706998

Related

Java: Format double with decimals and Format numbers in java

like image 71
user219882 Avatar answered Sep 30 '22 23:09

user219882