Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java (beginner) converting scientific notation to decimal

if

double d =  1.999e-4

I want my output to be 0.0001999.

How can I do it?

like image 329
hibc Avatar asked Oct 25 '12 08:10

hibc


People also ask

How do you use scientific notation in Java?

The format of scientific notation in Java is exactly the same as you have learned and used in science and math classes. Remember that an uppercase 'E' or lowercase 'e' can be used to represent "10 to the power of". Scientific notation can be printed as output on the console if it passes a certain number.

How do you decrypt scientific notation?

b is the power of 10 required so that the scientific notation is mathematically equivalent to the original number. Move the decimal point in your number until there is only one non-zero digit to the left of the decimal point. The resulting decimal number is a. Count how many places you moved the decimal point.


1 Answers

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

String f = formatter.format(d);  

You can explore the sub classes of NumberFormat class to know more details.

like image 147
RP- Avatar answered Sep 20 '22 07:09

RP-