• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Octal & Hexa Literals - Doubt

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
K&B book says, Octal numbers can have 21 digits (excluding the leading zero) and HexaDecimal numbers can have 16 digits (excluding the leading 0x/0X and the optional suffix L/l). But, the java compiler (1.5.0.10) is allowing more than this limit and giving the correct output aswell. Any explanation please?

The sample program I've tried goes here:

class OctalCheck
{
public static void main(String[] args)
{
int i = 00000000000000000000000010;
System.out.println("i :" + i);

int h = 0x00000000000000000f;
System.out.println("h :" + h);
}
}

Output:
i :8
h :15
 
Ranch Hand
Posts: 329
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried the following?


[ June 05, 2007: Message edited by: Sergio Tridente ]
 
Viswanath Konduri
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
int i = 0100000000000;

Even this will give a compiler error, as it exceeds the int limit. Then how can I check that?
 
Always! Wait. Never. Shut up. Look at this tiny ad.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic