Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • 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 ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

char literal

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

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
jaya
 
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
 
Doody calls. I would really rather that it didn't. Comfort me wise and sterile tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!