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

java.lang.math.Round returning a bad answer

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.1
    • core-libs
    • None
    • x86
    • windows_nt



      Name: sg39081 Date: 10/16/97


      double x = 1.0e+19
      double answer = java.lang.Math.round(x);

      bug: answer is -9.2233720368548e+018

      If x is 1.0e+18, round() returns correct answer''

      public class round
      {
              public static void main( String[]args)
              {
                      double x = 1.0e+19;
                      double answer = java.lang.Math.round(x);
                      System.out.println("x=" + x);
                      System.out.println("answer=" + answer);

                      x = 1.0e+18;
                      answer = java.lang.Math.round(x);
                      System.out.println("x=" + x);
                      System.out.println("answer=" + answer);
              }
      }

      ======================================================================

            hongzh Hong Zhang
            sgoodsunw Sheri Good (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: