This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
and I believe the max value allowed in a long is 9223372036854775807. Can someone confirm this? I keep getting this error when trying to compile:
integer number too large: 109275027171421
Any help would be appreciated!
Want a free iPod, digital camera, or $300 cash? Completely legit offer at <a href="http://www.geocities.com/pricklymustard/freestuff.html" target="_blank" rel="nofollow">http://www.geocities.com/pricklymustard/freestuff.html</a> . I am looking for referrals which is why I need YOU!
As Marc stated, by default literal numbers are of type int, however, the literal you have in your code '109275027171421' is too big to fit into an int. It has to be able to be able to fit into an int before it can be casted to long. However, you can append 'L' to the end of the literal to tell the compiler that this number should be treated as a long instead of an int. Then it will compile.
Originally posted by Mark Patrick: ...you can append 'L' to the end of the literal to tell the compiler that this number should be treated as a long instead of an int...
Of course. The literal itself must be designated as a long. Casting won't work because you can't even get the int to cast from. (I must be getting tired. Sorry...) [ December 01, 2004: Message edited by: marc weber ]
Joined: Nov 20, 2004
Many thanks! The second suggestion (appending L) worked!