Java outputs even numbers in exponential format

I have some even numbers output in this format:

Format.String("%1.4e",doubleNumber);

The result is 1.123456e 03 How to set the number of exponential passwords in this format:

1.123456e+003

I always have three passwords after the e symbol thank you

Update 1:

I have partially solved:

DecimalFormat formatter = new DecimalFormat("0.000000E000");

System. out. println(formatter.format(doubleNumber));

Now numbers are always in format

1.123456e0xx

or

1.123456e-0xx

But not all of them have been solved I will always print the logo:

1.123456e+0xx or 1.123456e-0xx

What can I do? http://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html

Solution

There is no built - in way to do this, you have to do it yourself

The easiest way is to format as you do, and then add extra zeros as needed

In addition, it is string Format, not format String, and the "% 1.4e" format you give will result in 1.1235e 03 instead of 1.123456e 03

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>