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

double-to-String conversion can result in extra digits

    Details

    • Subcomponent:
    • Understanding:
      Cause Known
    • CPU:
      unknown, x86
    • OS:
      generic, solaris_7, windows_nt, windows_2000

      Description

      Conversion of a double value (and perhaps a float) to String
      can result in more digits than are absolutely necessary, contrary to the JLS.
      Attached is mail giving an number of good examples.

      Name: yyT116575 Date: 03/13/2001


      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

      Execute the following class:

      public strictfp class Test
      {
          static public void main(String [] arg)
          {
              float f = 23.56f;
              double d = f;
              System.out.println(f + " " + d);
          }
      }

      The result is:

      23.56 23.559999465942383

      It seems that the results contradicts Java specification that explicitly says
      that conversion from float to double in a strctfp expression should not lose
      precision
      (Review ID: 118747)
      ======================================================================
      ###@###.### 2004-11-11 21:43:45 GMT

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                bpb Brian Burkhalter
                Reporter:
                duke J. Duke (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Imported:
                  Indexed: