• 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

is char unsigned 16 bit?

 
Ranch Hand
Posts: 689
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why datatype char is said to be unsigned ?
actually what is the difference between signed and unsigned?
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A sign bit is used to indicate the sign of a number. Depending on whether the bit is 1 or 0 the number is considered positive or negative. A char need not be signed because it is used to represent unicode characters. Negative unicode characters just dont make sense. So a char is 16 bit unsigned.
 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The reason this is interesting is that by not supporting signed numbers a char can contain a larger number than say a short (also 16bit but supports signed numbers).

short can hold a number up to 2^15 - 1
char can hold a number uup to 2^16 - 1

Yes, chars are not meant to hold numbers...but you can assign a number to them.

See this post > https://coderanch.com/t/259063/java-programmer-SCJP/certification/char-representation-was-please-guide
 
saikrishna cinux
Ranch Hand
Posts: 689
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok thanks but how many datatypes are there in java which has got both signed and unsigned ?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic