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

Maximum value of long datatype is displaying as an out of range error

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "1.8.0_131"
      Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
      Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Windows 10

      A DESCRIPTION OF THE PROBLEM :
      Maximum and the minimum value of the long data type is displaying as an error.
      1. create a variable data type as long
      2. give the maximum or minimum value of long data type (2^63-1)
          eg: maximum = 9223372036854775807
                 minimum = -9223372036854775808
      3.print the program.
      4.verify the error

      public class DataTypes{
      public static void main(String args[]){
      long lMaximum = 9223372036854775807;
      System.out.println("Maximum value=" +lMaximum);

      }
      }

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. create a variable data type as long
      2. give the maximum or minimum value of long data type
          eg: maximum = 9223372036854775807
                 minimum = -9223372036854775808
      3.print the program.
      4.verify the error

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      the maximum and the minimum value should display
      ACTUAL -
      Displaying an error

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      DataTypes.java:16: error: integer number too large: 9223372036854775807
                      long lMaximum = 9223372036854775807;
                                                      ^
      1 error


      REPRODUCIBILITY :
      This bug can be reproduced always.

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

              Created:
              Updated:
              Resolved: