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

java.lang.Bignum.integerDivide(), remainder() methods work wrong

    XMLWordPrintable

Details

    • 1.1
    • sparc
    • solaris_2.5
    • Not verified

    Description

      These methods work wrong with negative or non-integral parameters.
      ==== Here is the minimized test demonstrating the bug ====
      import java.lang.Bignum;
      class java_lang_Bignum_integerDivide {
        public static void main(String args[]) {
           Bignum b1=new Bignum("35.12");
           Bignum b2=new Bignum("5");
           System.out.println(b1.integerDivide(b2)[0]); // should print 7
           System.out.println(b1.integerDivide(b2)[1]); // should print 0.12
           System.out.println(b1.remainder(b2)); // should print 0.12

           b1=new Bignum("-35");
           b2=new Bignum("5");
           System.out.println(b1.integerDivide(b2)[0]); // should print -7
           System.out.println(b1.integerDivide(b2)[1]); // should print 0
           System.out.println(b1.remainder(b2)); // should print 0

        }
      }
      ===== Here is the output of the test =====
      7
      .02
      .02
      0
      -35
      -35

      Attachments

        Activity

          People

            mhapnersunw Mark Hapner (Inactive)
            mgorshen Mikhail Gorshenev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: