Quote:
|
Originally Posted by zoliky
Charachter x in binary is: 01111000. This charachter use 7 bit: 1111000. right ?
|
01111000 is 8 bits
1111000 is 7 bits
When using c and c++ the size of each type is dependant upon your machine, but a char is normally 8 bits
and that's correct. 8 bits = a byte
Quote:
|
But I don't understand why number 500 is 2 byte. Someone explain this thing for me ?
|
It depends on the datatype. An int is 32 bits and a short int is 16 bits or two bytes. More bits = more storage space. A short int (2 bytes) storing the number 500 has more storage space than a char (8 bits) storing x.
Simply put, numeric types are larger and have more storage space than chars. A char is a single character and can't hold the number 500.