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

Output of float operation as String gives inconsistent results

    Details

    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      ADDITIONAL SYSTEM INFORMATION :
      using java 12.0.1

      A DESCRIPTION OF THE PROBLEM :
      System.out.println(4+3.14f+"aabc"); gives 7.1400003aabc but
      System.out.println(5+3.14f+"aabc"); gives 8.14aabc why?


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      run System.out.println(4+3.14f+"aabc");
            

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      7.14aabc
      ACTUAL -
      7.1400003aabc

      ---------- BEGIN SOURCE ----------
      public class TestInt{

      public static void main(String args[]){

      System.out.println(5+3.14f+"aabc");

      }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                bpb Brian Burkhalter
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: