8 Replies Latest reply: Aug 29, 2013 4:48 AM by jwenting RSS

    Core Java Issue in decimal division....SOS!!!!

    Raghoo

      Hi People,

       

      I was just wondering the reason for below output generated in java.

       

      double d2 = 0.142;

      double d3 = d2/100;

      System.out.println(d3);

       

      Output = 0.0014199999999999998

      But if i do in calculator i get 0.00142

       

      double d2 = 0.152;

      double d3 = d2/100;

      System.out.println(d3);

       

      Output = 0.0015199999999999999

      But if i do in calculator i get 0.00152

       

       

      Any help is highly appreciated.