M
M
mond_bond2017-03-15 22:27:43
Java
mond_bond, 2017-03-15 22:27:43

JAVA. The result of dividing by a large number?

I divide let's say:
double res = 203.45 / 167566.0;
I get it, everything is fine:
0.001214148454937159
But when I divide already with such a number:
double res = 203.45 / 267566.0;
I get the result:
7.603731415800213E-4
How to make the result similar to the first option?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Stolyarov, 2017-03-15
@mond_bond

double d = 1E-10;
NumberFormat nf = NumberFormat.getInstance();
nf.setMaximumFractionDigits(Integer.MAX_VALUE);
System.out.println(nf.format(d));

Source

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question