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

double and float not calculating correctly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 1.2.2
    • core-libs
    • generic
    • generic



      Name: yyT116575 Date: 03/26/2001


      java version "1.2.2"
      Classic VM (build JDK-1.2.2_006, native threads, symcjit)

      I'm getting the wrong values returned off a division with both float and double
      variables... The correct value for p should be 1.84, for some reason, its
      returning 1.8399999999999999.

      public class floattest {
          
        public static void main( String[] args) {

          double w, c, p;
          w = 1280.00;
          c = 2355.20;
          System.out.println("w = " + w + "\n");
          System.out.println("c = " + c + "\n");
          p = c / w;
          System.out.println("p = " + p + "\n");

        }
      }
      (Review ID: 119499)
      ======================================================================

            darcy Joe Darcy
            yyoungsunw Yung-ching Young (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: