Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

99999999999 is out of range

 
Anton Hassan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following declaration:
static long MAXNUMBER = 99999999999;
Why do I get an error message: "99999999999"? Isn't the largest number for long is "(2 to the power of 63) - 1"?
I'm using Eclipse as the IDE.
Help. Thank you.
 
Chris Harris
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Anton,
If you want to get the max value of a long use:

The max value is 9223372036854775807.
If you want to set a long to 9999999999 try

Hope that helps
Chris
 
Anton Hassan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, Chris.
I wanted to make 99999999999 a long and your advice was a great help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic