inpyjama / c-ninja-listings

Lower level assembly and C baremetal programming on RISC-V CPUs. Source code listings from the C-Ninja, in Pyjama! book.
https://inpyjama.com
90 stars 460 forks source link

signed vs unsigned char #27

Open sreemoorthy opened 8 months ago

sreemoorthy commented 8 months ago

if Char is used for representing ASCII symbols, what is the significance of having a signed and unsigned 'char'?. does a signed and unsigned char point to a different symbol or the same symbol?. if they both represent the same symbol why the extra keyword usage?

streetdogg commented 8 months ago

if Char is used for representing ASCII symbols, what is the significance of having a signed and unsigned 'char'?

char is used to save the number associated with a character as per the ASCII table.

does a signed and unsigned char point to a different symbol or the same symbol?.

  1. only positive numbers point to a symbol. The ASCII table has only 128 entries - https://www.cs.cmu.edu/~pattis/15-1XX/common/handouts/ascii.html
  2. The negative numbers don't represent any symbol.