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

Octal addition incorrect

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • 9
    • 7u60
    • client-libs
    • x86
    • windows_2008

      FULL PRODUCT VERSION :
      Microsoft Windows [Version 6.0.6002]
      Copyright (c) 2006 Microsoft Corporation. All rights reserved.

      C:\Users\Administrator>java -version
      java version "1.7.0_55"
      Java(TM) SE Runtime Environment (build 1.7.0_55-b14)
      Java HotSpot(TM) Client VM (build 24.55-b03, mixed mode, sharing)



      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.0.6002]
      Copyright (c) 2006 Microsoft Corporation. All rights reserved.



      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Netbeans IDE 7.4

      A DESCRIPTION OF THE PROBLEM :
      *
       * @author Administrator
       */
      public class Calculator {
          public static void main (String[] args)
          {
              Calculator c = new Calculator();
              //preceeding numbers with a zero means that they are in octal.
              System.out.println(c.add(01000, 03000));
          }
          public int add (int a, int b)
          {return a + b;}
          
      }

      REGRESSION. Last worked in version 7u55

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      1000 + 3000 = 4000
      Tested this using Windows Calculator in Octal mode.
      ACTUAL -
      run:
      2048
      BUILD SUCCESSFUL (total time: 0 seconds)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      *
       * @author Administrator
       */
      public class Calculator {
          public static void main (String[] args)
          {
              Calculator c = new Calculator();
              //preceeding numbers with a zero means that they are in octal.
              System.out.println(c.add(01000, 03000));
          }
          public int add (int a, int b)
          {return a + b;}
          
      }
      ---------- END SOURCE ----------

            serb Sergey Bylokhov
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: