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

error on comparing max value of Long type variable

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      windows_10

      Description

      ADDITIONAL SYSTEM INFORMATION :
      OS : Windows 10
      Java Runtime :

      C:\Users\dbgud>java -version
      java version "1.8.0_211"
      Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
      Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)

      A DESCRIPTION OF THE PROBLEM :
      comparing max value of Long type variable makes an error,

      Let's see the code:

      long a = 9223372036854775807L;
      long b = 9223372036854775807L;
      System.out.println(a == b);

      this returns true;

      but,
      Long a = 9223372036854775807L;
      Long b = 9223372036854775807L;
      System.out.println(a == b);

      this returns false

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      run the code below:

      Long a = 9223372036854775807L;
      Long b = 9223372036854775807L;
      System.out.println(a == b);

      ACTUAL -
      false

      CUSTOMER SUBMITTED WORKAROUND :
      changing type of variable from Long to long

      FREQUENCY : always


        Attachments

          Activity

            People

            Assignee:
            psonal Pallavi Sonal (Inactive)
            Reporter:
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: