Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7081271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:53:57+00:00 2026-05-28T06:53:57+00:00

Why do I get an int number is too large where the long is

  • 0

Why do I get an int number is too large where the long is assigned to min and max?

/*
long: The long data type is a 64-bit signed two's complement integer.
It has a minimum value of -9,223,372,036,854,775,808 and a maximum value of         9,223,372,036,854,775,807 (inclusive).
Use this data type when you need a range of values wider than those provided by int.
*/
package Literals;

public class Literal_Long {
     public static void main(String[] args) {
        long a = 1;
        long b = 2;
        long min = -9223372036854775808;
        long max = 9223372036854775807;//Inclusive

        System.out.println(a);
        System.out.println(b);
        System.out.println(a + b);
        System.out.println(min);
        System.out.println(max);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T06:53:58+00:00Added an answer on May 28, 2026 at 6:53 am

    All literal numbers in java are by default ints, which has range -2147483648 to 2147483647 inclusive.

    Your literals are outside this range, so to make this compile you need to indicate they’re long literals (ie suffix with L):

    long min = -9223372036854775808L;
    long max = 9223372036854775807L;
    

    Note that java supports both uppercase L and lowercase l, but I recommend not using lowercase l because it looks like a 1:

    long min = -9223372036854775808l; // confusing: looks like the last digit is a 1
    long max = 9223372036854775807l; // confusing: looks like the last digit is a 1
    

    Java Language Specification for the same

    An integer literal is of type long if it is suffixed with an ASCII letter L or l (ell); otherwise it is of type int (§4.2.1).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following function: //Function to get random number public static int RandomNumber(int
I need to get UserCarId(int) from this query and assign to int type variable.
I have multiple controller actions that takes an id public ActionResult Get(int? id) {
Does anyone know of a List implementation that has a constant time get(int index)
As input I get an int (well, actually a string I should convert to
How can I get the int value from a string such as 423e -
class Foo { public int A { get; set; } } class Program {
Assuming public class MyClass { public int ID {get; set; } public string Name
Is there any way to get input from a file one number at a
I started assembly (nasm) programming not too long ago. Now I made a C

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.