java.lang.math.Round returning a bad answer

XMLWordPrintable

    • Type: Bug
    • Resolution: Duplicate
    • Priority: P3
    • None
    • Affects Version/s: 1.1
    • Component/s: 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);
              }
      }

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

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: