double and float not calculating correctly

XMLWordPrintable

    • Type: Bug
    • Resolution: Not an Issue
    • Priority: P4
    • None
    • Affects Version/s: 1.2.2
    • Component/s: 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)
      ======================================================================

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: