Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to access the numbers greater than 2147483648(2^31) in java..

This is a small code compiled
C#
import java.io.*;
class Testlong
{public static void main(String args[]) throws Exception
 {
 long i=600851475143;
 System.out.println(i);
 }
 }


on the compilation i get following error

javac Testlong.java
Process started >>>
Testlong.java:5: integer number too large: 600851475143
long i=600851475143;
^
1 error
<<< Process finished.


any help..?
thanks in advance

sreedhar
Posted
Updated 24-Jul-11 23:05pm
v2
Comments
Firo Atrum Ventus 25-Jul-11 5:00am    
You still ask this question despite the fact that you already aware of the existence of long data type. Hmm... What's your real question?

Use the long data type.
 
Share this answer
 
Use Java long type which is signed 64-bit; -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 (inclusive), see http://download.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html[^].

—SA
 
Share this answer
 
 
Share this answer
 
In order to insert a hardcoded long use long literal like this:
long i=600851475143l;


More details here.[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900