Java - long - Long (integer 64 bit)

1 - About

A long variable is an integer on 64 bit. (May be Computer Number - Float64 (64-bit or double precision) floating-point number)

For an integer on 32bit, see Java - Integer

The primitive wrapper Long is a subclass of Number in java

3 - Implementation

3.1 - Primitive Integer

Long is an integer that is encoded with 64 bit but you have also int on 32 bit.

Primitive Type Primitive Wrapper Stored in a word of min max
int Integer 32 bits <math>-2^{31}</math>
long Long 64 bits <math>-2^{63}</math>

3.2 - Long

4 - Management

4.1 - Initialization

long = 1.073.741.824L;

  • From a variable

long = (long)a;

  • from an integer

Long i = theinteger.longValue()

  • from an int

Long i = Long.valueOf(3);

4.2 - Operation

Number - (Arithmetical | Numerical | Mathematical) Operators on long

The operations are done in the largest data type required to handle all of the current values.

For the below mathematics Operations The operation is a
int (operator) int integer operation
int (operator) long long operation


  • a long operation

long i = (int)1 * (long)2

  • a int operation

long i = (int)1 * (int)2

4.3 - To Int

Long theLong;
Integer i = theLong.intValue()

  • or from a long primitive


Data Science
Data Analysis
Data Science
Linear Algebra Mathematics

Powered by ComboStrap