Rounding error at 14th decimal place only for values ending in number 7

XMLWordPrintable

    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      IC-221.6008.13, JRE 11.0.15+10-b2043.56x64 JetBrains s.r.o., OS Windows 11(amd64) v10.0 , screens 2880.0x1620.0, 2560.0x1440.0

      A DESCRIPTION OF THE PROBLEM :
      Rounding error is observed every time for numbers ending in 7

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      public class Main {

          public static void main(String[] args) {
              
              double price = 100.00;
              double finalPrice = price + 18.97233443342187111;
              System.out.println(finalPrice);


          }
      }

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      118.97233443342187
      ACTUAL -
      118.97233443342188

      FREQUENCY : always


            Assignee:
            Andrew Wang
            Reporter:
            Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: