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

The return value of BigDecimal.toString method is different when run against 1.4 vs 1.5

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 5.0
    • core-libs
    • x86
    • windows_xp

      J2SE Version (please include all output from java -version flag):
        C:\java\j2sdk1.5.0_beta2\bin>java -version
         java version "1.5.0-beta2"
         Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b51)
         Java HotSpot(TM) Client VM (build 1.5.0-beta2-b51, mixed mode, sharing)

      Does this problem occur on J2SE 1.4 or 1.4.1 or 1.4.2? Yes / No (pick one)
         NO

      Operating System Configuration Information (be specific):
        OS Name Microsoft Windows XP Professional
        Version 5.1.2600 Service Pack 1 Build 2600

      Bug Description:
        Behavior of BigDecimal.toString has changed. In J2SE 1.4.x and prior, the
        BigDecimal.toString method returned the string representation of the value
        1E-15 as 0.000000000000001. In J2SE 1.5 the toString method returns the
        value 1E-15 as 1.0E-15.

        While I understand this was done intentionally, this does cause a problem
        in our product which makes J2SE 1.5 not backward compatible with our product.

        It is easy enough to fix in our product, but I felt we should at least point
        out the issue.

      Steps to Reproduce (be specific):

      BigDecimal bd = new BigDecimal("1E-15");
      String val = bd.toString();

                      bd = new BigDecimal(".000000000000001");
                      val = bd.toString();

      The value returned by both two string methods will be different when run against 1.4 vs 1.5

      ###@###.### 2005-07-19 18:03:55 GMT

            darcy Joe Darcy
            tyao Ting-Yun Ingrid Yao (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: