Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 06-27-2008, 02:53 PM   #1
Registered: Jul 2004
Distribution: Ubuntu
Posts: 387

Rep: Reputation: 33
Post Java: Quick question about primitive data type long.

I have a variable of type long (primitive, so range is 2^63) called size.

I have the following code that is giving me an error:

else if(size<=1099511627776)
I'm getting the error "The literal 1099511627776 of type int is out of range". So it seems that when comparing size with 1099511627776, it's comparing data type long with an integer.

How do I overcome this problem?

I tried placing the value I'm trying to compare into another long variable, but I can't assign the value 1099511627776 to it because I get the same error.

Thanks for any guidance,
Old 06-27-2008, 03:41 PM   #2
LQ Newbie
Registered: Apr 2008
Distribution: Slackware 12.0 Kernel 2.6.25, LFS Kernel
Posts: 25

Rep: Reputation: 15
Use an L qualifier, I'm guessing it's treating the literal value as a normal int so:

else if( size<=1099511627776L )
Old 06-27-2008, 04:11 PM   #3
Senior Member
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Originally Posted by vxc69 View Post
How do I overcome this problem?
wget is right. You have to declare large numbers using the "L" qualifier or you get a compiler error like that. Otherwise, the compiler thinks you are trying to jam that much information into its default type (int) and it will not fit.
Old 06-27-2008, 04:46 PM   #4
Registered: Jul 2004
Distribution: Ubuntu
Posts: 387

Original Poster
Rep: Reputation: 33
Thanks guys, it worked! Wasn't aware of the L qualifier.


compile, error, int, java, numbers, type

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Type Java Arrays InJesus Programming 3 01-07-2006 05:09 PM
Quick Java question Nylex Programming 2 01-26-2004 12:44 PM
quick question - java Laptop2250 Programming 2 10-15-2003 09:56 PM
Quick Java plug-in question Tyir Linux - Newbie 4 10-09-2003 01:58 PM
Quick question: Does Java 1.4.2 unstable in your PC? codec Linux - Software 3 09-16-2003 11:24 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:52 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration