Java double data type problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Rameshwar Soni
    New Member
    • May 2011
    • 3

    Java double data type problem

    can anyone explain me the output of the following program :
    Thanks in advance

    // program

    Code:
    class No_System_Demo
    {
      public static void main(String[] n) 
      {
        double d=020;	// octal no 20 stored
        System.out.println("d=" +d);    // output will be in decimal number system and is 16.0 and thats fine
    		
        
       double d1=020.0;   // octal no's can have a decimal so     the same no 20 or say 20.0 is stored
       System.out.println("d1=" +d1);  // but this time why the output isn't in decimal number system, it displays 20.0 instead of 16.0
    		
       }
    }
Working...