File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Literals

 
Adi Sharma
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,

I was reading that "You can have up to 21 digits in an octal number and 16 digits in an hexadecimal number " ,But when I tried it, it says type int out or range.

Help please

Thnks
Aditya Sharma
 
Faisal Ansari
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try putting a prefix 0 before the octal number and 0x before the hexadecimal number...
 
Adi Sharma
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that the answer is that if you declare the variables of type 'long' and not 'int', then the octal value can have 21 digits and hexadecimal can have 16 digits. But if you use 'int', then it turns out to be out of 'int' range .

Please correct me if I am wrong.

Thanks
Aditya Sharma
 
Rob Spoor
Sheriff
Pie
Posts: 20372
44
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Long.MAX_VALUE is 0x7FFFFFFFFFFFFFFF, so 16 characters (excluding the 0x), and 0777777777777777777777, so 21 characters (excluding the leading 0). So yes, these limits hold for long.

Integer.MAX_VALUE is 0x7FFFFFFF (8 characters) and 017777777777 (11 characters).
 
Adi Sharma
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic