0

I am new to programing.

I was wondering why are bytes 8 bits? why cant a byte be expanded to n bits instead of taking 8 bytes to make 64bit?

Thanks!

Sorry, my question was not phrased right. When windows writes a file, the smallest possible is a byte of 8 bits. Why can't it be more than that?

I assume char_bit is in memory process. the file written out will still be a byte of 8 bits, yes?

csaw
  • 172
  • 11
  • 2
    If you [search](http://stackoverflow.com/search?q=8+bit+byte), you'll find lots of other already-answered questions about this. [1](http://stackoverflow.com/questions/13615764) [2](http://stackoverflow.com/questions/18576822) [3](http://stackoverflow.com/questions/881894). – Jonathon Reinhart Mar 07 '14 at 07:32
  • Have a look on [What is CHAR_BIT?](http://stackoverflow.com/questions/3200954/what-is-char-bit) for some more clarification. – Dayal rai Mar 07 '14 at 07:33
  • 1
    It all boils down to this question: "What is the smallest unit of data that my system can process?" Even though an x86_64 machine will have 64-bit general purpose registers, the registers and memory is still byte-addressable, where a byte is 8 bits. This forms the definition of `CHAR_BIT`, mentioned below. – Jonathon Reinhart Mar 07 '14 at 07:37
  • Some Texas Instruments CPUs have 16 bits as lowest processable unit; they cannot load, store or process bytes but only 16 bit words. Low-level CPUs (used for cheap TV remote controls) use 4 bits per unit instead of 8. – Martin Rosenau Mar 07 '14 at 08:49
  • An important constraint comes from the C memory model: Different elements of an array are different access locations, and concurrent, unordered access of two different array elements is defined to not be a data race. Applying this to `char` arrays, you find that the hardware must support access to individual bytes without inventing writes, which puts constraints on the size of a byte. – Kerrek SB Mar 07 '14 at 09:39

1 Answers1

1

It actually can - the number of bits in a byte is CHAR_BIT, which is 8 most of the time, but doesn't have to.

Luchian Grigore
  • 253,575
  • 64
  • 457
  • 625
  • 2
    @user4815162342 yes it does - "byte - addressable unit of data storage large enough to hold any member of the basic character set of the execution environment" – Luchian Grigore Mar 07 '14 at 07:33
  • 1
    @user4815162342 and "number of bits for smallest object that is not a bit-field (byte) CHAR_BIT" – Luchian Grigore Mar 07 '14 at 07:35