• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

char literal

Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

i need a help..

How to identify the valid char literal when hexa or octal number assigned?

how r these valid char literals???

char a = 0x7fffffff;

char b = 0Xbeef;

char c = '\uface' ;

char d = 0xadcafe;

I'm confused like how to indentify if a hexa decimal is valid char literal same with octal too..how to know it falls wihtin range of char...do i need make conversion r is there any shortcut to identify.

Thankyou in advance
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello jaya,
u see u must understand three steps to identify whether the
given number is valid hex number or not,

1. it must begin with 0x OR 0X.
2. it can have digits and numbers 1,2,3,4,5,6,7,8,9,a,b,c,d,e,f
3. each number in a hex number represents corresponding four digits in
binary format of the given number i.e.
for example consider the number 0x8eda which in binary format becomes

8 e d a
1000 1110 1101 1010

so u see by this we come to know whether the number is exceeding the 16
bits assigned for char literal.we can also find the value of the hex number easily.

one more point when using th 0xYYYY format we can have less than 4 digits or numbers but when we use unicode representation we must have four numbers or digits i.e.

'\u00a' ---> invalid
'\ucafe' ---> valid
0x00a ----> valid
0xcafe ---> valid

according to me to find whether a number is valid octal number or not there are 2 steps

1. number should start with 0.
2. number must have only digits and that too only 0,1,2,3,4,5,6,7
janne s
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi anand,

thank you
Always look on the bright side of life. At least this ad is really tiny:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic