Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4039112

Too many significant digits in floating point output

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P5 P5
    • None
    • 1.1
    • core-libs
    • None
    • sparc
    • solaris_2.5.1



      Name: sgC58550 Date: 03/14/97


      public class fp {
          public static void main(String argv[]) {
              System.out.println(3 * 0.2);
              System.out.println(0.6000000000000001);
              System.out.println(0.6);
          }
      }

      Run this program under JDK 1.0.2, and it prints all 0.6.
      When run under JDK 1.1 *even if it was compiled under JDK 1.0.2*
      The first two numbers are output as 0.6000...0001
      company - Univ. of Calif. at Santa Barbara , email - ###@###.###
      ======================================================================

            mr Mark Reinhold
            sgoodsunw Sheri Good (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: