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.
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.