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

In java.math.BigDecimal, division by one returns zero

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 8
    • 5.0
    • core-libs
    • b106
    • x86
    • linux
    • Verified

    Description

      FULL PRODUCT VERSION :
      java version "1.5.0_05"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)
      Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)


      ADDITIONAL OS VERSION INFORMATION :
      Linux 2.6.11-6mdk #1 Tue Mar 22 16:04:32 CET 2005 i686 Intel(R) Pentium(R) 4 CPU 2.26GHz unknown GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      Dividing ONE with a very high negative scale, by ONE return ZERO

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      (new BigDecimal(BigInteger.ONE, Integer.MIN_VALUE)).divideToIntegralValue(BigDecimal.ONE)


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      1E+2147483648
      ACTUAL -
      0E+2147483648

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.math.*;
      public class BugDivide{
          public static void main(String[] args){

              System.out.println((new BigDecimal(BigInteger.ONE, Integer.MIN_VALUE)).divideToIntegralValue(BigDecimal.ONE));
          }
      }
      ---------- END SOURCE ----------

      Attachments

        Issue Links

          Activity

            People

              bpb Brian Burkhalter
              ndcosta Nelson Dcosta (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: