Results 1 to 4 of 4
- 04-24-2012, 03:21 AM #1
Member
- Join Date
- Apr 2012
- Posts
- 74
- Rep Power
- 0
The literal of type int is out of range?
Hello, I've just started a new piece of code and am getting an error already:
The literal 600851475143 of type int is out of range
The error is for the number:600851475143. Am I using long incorrectly?Java Code:public class Problem3 { public static void main (String args[]){ long y, x; y=600851475143; for (x=0,x<600851475143,x++){ } } }
Cheers!
-
Re: The literal of type int is out of range?
You're forgetting the "L" that needs to be appended to the end of a long literal:
You're also forgetting to add spaces to your code. :)Java Code:public class Problem3 { public static void main (String args[]) { long y = 600851475143L; for (long x = 0L; x < 600851475143L; x++) { } } }
edit: and semicolons in the for conditionLast edited by Fubarable; 04-24-2012 at 03:32 AM.
- 04-24-2012, 03:30 AM #3
Senior Member
- Join Date
- Apr 2012
- Location
- New York State of Confusion, USA
- Posts
- 137
- Blog Entries
- 1
- Rep Power
- 0
Re: The literal of type int is out of range?
There are limits to the values that can be stored in the various numeric data types. You should read the Primitive Data Types Tutorial to understand them.
Beaten by the Fubarable...I'm going to bed!
- 04-24-2012, 04:33 AM #4
Member
- Join Date
- Apr 2012
- Posts
- 74
- Rep Power
- 0
Similar Threads
-
Change Literal String to File Path with speratorChar
By Jeremiah in forum New To JavaReplies: 2Last Post: 08-18-2011, 07:14 PM -
Filtering with Pattern, use metacharacters as a literal
By nenadm in forum Advanced JavaReplies: 2Last Post: 02-04-2011, 10:10 PM -
What is the difference between Inline literal and Static final String in Java.
By devaru2003 in forum Advanced JavaReplies: 3Last Post: 03-26-2010, 07:09 AM -
Regex - matching literal characters
By racha0601 in forum Advanced JavaReplies: 3Last Post: 04-07-2009, 11:25 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks