How to show + sign in scientific notation.
Posted on 2004-09-05
I want to convert an integer number into scientific number format with a plus sign after E.
e.g. I want to print 5 as .50000E+01 . Is this possible in Java. I have given below the code snippet I used in my program but with that it doesn't show a + sign. Can anybody help to solve this problem ?
int myNumber = 5;
String myFormat = ".00000E00";
NumberFormat nf = NumberFormat.getInstance();
DecimalFormat df = (DecimalFormat)nf;
System.out.println( "[" + myNumber +"]: " + df.format(myNumber) );