Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Display a Java Double in non scientific format

843785Jul 3 2008 — edited Jul 3 2008
Hi,

I have a small program which I need to display double values with System.out.println.
public class SmallNumber
{
    public static void main(String args[])
    {
          Double double1 = new Double(0.0001);
          Double double2 = new Double(0.001);

         System.out.println(double1 );//Prints 1.0E-4
          System.out.println(double2 );//Prints 0.0010
    }
  
}
Why does java print double value (0.0001) in scientific notation(1.0E-4). Is there a way that I can print 0.0001 as it is.

Thanks,
Chamal.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 31 2008
Added on Jul 3 2008
5 comments
4,774 views