Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is the smallest value that can be stored is a Byte(8bit) & not a Bit(1bit)?

Tags:

memory

byte

cpu

bit

Why is the smallest value that can be stored a Byte(8bit) & not a Bit(1bit) in memory? Even booleans are stored as Bytes. Will we ever bump the smallest number to 32 or 64bits like register's on the CPU?

EDIT: To clarify as many answers seemed confused about the nature of questing. This question is about why isn't a byte 7-bit, 1-bit, 32-bit, etc (not why lower bit primitives must fit within the hardware's byte at min). Is the 8-bit byte simply historical as some hardware has 10-bit bytes for example. Or is there a mathematical reason 8-bit is ideal vs say 10-bit for general processing?

like image 427
zezba9000 Avatar asked Dec 02 '25 08:12

zezba9000


2 Answers

The hardware is built to read data in blocks (bytes, later words and dwords). This provides greater efficiency, than accessing individual bits, and also offers more addressing range. So most data is aligned to at least byte boundary. There exist encodings that operate with bit sequences, rather than bytes, but they are quite rare.

Nowadays the data is most often aligned to dword (32-bits) boundary anyway. Moreover, some hardware (ARM, for example), can't access misaligned multibyte variables, i.e. 16-bit word can't "cross" dword boundary - exception will be thrown.

like image 72
Eugene Mayevski 'Callback Avatar answered Dec 03 '25 23:12

Eugene Mayevski 'Callback


Because computers address memory at the byte level, so anything smaller than a byte is not addressable.

like image 42
Eric Petroelje Avatar answered Dec 04 '25 00:12

Eric Petroelje



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!