• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Representation of character literal in octal format.

 
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am always confused with representation of character literal. Here are two of my basic doubts,
1. char c=533; // Is valid one.
2. char c1 = '\1025'; // compile time error.
Why i am getting the error at line no 2. When i convert the octal number 1025 to decimal, it is equivalent to 533.
Some where i read that, when assigning the octal value to the character, its value should be between 000 and 377 - Why is this limit?
One more thing, when i am using Unicode representation, number of characters after \u should be less than 5. Even the below one is not valid,
char c2 = '\u00001';
Why is this limit??
I hope some will clarify all these doubts.
Thanks a lot,
Narasimha.
 
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
because your second line is trying to get an unicode character, with using \ but not using the u so try it with \uwhatever number
octal numbers as far as i remember always have a preceeding 0 like 010 or 022526
hexadecimal numbers are 0x123 or 0X0023 the 0x gives it away
decimal is just normal numbers 1234567890
remember chars can only go from 0 to 65535, you can use an int number as long as its in range.
this may help
Davy
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic