0

As far as integers, floats, double are concerned there -ve range exists because number can be -ve as well as +ve but:

  • Why char too have a -ve range from -128 as char is character ( i mean how can it be -ve )?

Can anybody help me to understand logic behind this ?

AlvaroAV
  • 10,335
  • 12
  • 60
  • 91
James
  • 35
  • 4
  • 2
    possible duplicate of [Why is 'char' signed by default in C++?](http://stackoverflow.com/questions/17097537/why-is-char-signed-by-default-in-c) – dandan78 Aug 28 '14 at 09:13
  • 2
    Please note that `char`, `signed char` and `unsigned char` are distinct types. `char` can be signed or unsigned, depending on the platform. – pts Aug 28 '14 at 09:13
  • 1
    Sometimes people use `char` for calculations (not for processing of characters). Many years ago it was necessary to economy memory :) So programmers had to use `char` for processing of small integer values. – Ilya Aug 28 '14 at 09:15

1 Answers1

-1

this is historic. 7 bits are all you needed for US-ASCII Characters plus control characters (CR, LF, RET, BS, ...), so you had one bit left for other use (EOF f.e.). To represent this, char was designed as signed.

Peter Miehle
  • 5,984
  • 2
  • 38
  • 55