12

I find several sources claiming that power-of-two bits in a binary word (such as 8-bits per byte) is a "good thing" or "convenient". I find no source pointing out why.

From What is the history of why bytes are eight bits? we read in the approved answer:

Binary computers motivate designers to making sizes powers of two.

Ok, but why? In the same question but in the comment field for the question I find:

Is the last sentence in jest? A 12-bit byte would be inconvenient because it's not a power of 2. - robjb

Again, void of rationale...

address calculations are a heck of a lot simpler with powers of 2, and that counts when you're making logic out of raw transistors in little cans - Mike

As bytes are the smallest addressable unit, this does not make much sense. Lots of upvotes on the comment though. Maybe I missed something.

From Wikipedia:

The de facto standard of eight bits is a convenient power of two permitting the values 0 through 255 for one byte

And this would be convenient because...?

For clarification, this is about the number of bits per byte (e.g. 8 or 6, etc), not the number of values per byte (e.g. 28 or 26, etc). Because of the confusion I also point out this is not about Word sizes.

I´m not overly interested in historical reasons. Those have been well explained elsewhere (see links).


Related question on SO: https://stackoverflow.com/questions/1606827/why-is-number-of-bits-always-a-power-of-two

Andreas
  • 299

6 Answers6

10

I don't think 8-bit bytes have been successful because they have a width which is a power of two. If you don't want to address bits individually -- and that's a common feature neither now nor in the past -- having a power of two is of no real practical importance (it's just -- now far more than in the past when sparing some discrete components was important -- a reflex for hardware and software engineers and staying in familiar ground is important for other purposes), and I don't remember having seen mentioned in my history of computing readings(1). One needed lower cases, that meant something more than the then dominant 6-bit character sets. ASCII was 7-bit, but ASCII was then though of purely as for inter-exchange (and thus to be translated to internal code for handling), and thus

The Subcommmitee recognizes that computer manufacturer are unlikely to design computers that use 7-bit codes internally. They are more likely to use 4-bit, 6-bit, and 8-bit codes. There is no widespread need at the present for interchange of more than 128 separate and distinct characters between computers, and between computers and associated input/output equipment. [paper tape, which had a natural frame size of 8 bits but needed parity so the payload of a frame was 7 bits is also cited in favor of 7-bit char for ASCII, power of two is not cited among the advantages of 8 bits] (2)

and for the hardware 8-bit byte won because it allowed to pack 2 decimal digits in one byte at a time when 75% of the data was numerical and represented in BCD(3).

(1) for instance Blaauw and Brooks, Computer Architecture; MacKenzie, Coded Character Sets, History and Development have both a discussion on that subject.

(3) Document of X3.2 -- the Subcommitee responsible of ASCII -- cited by MacKenzie.

(3) MacKenzie, again.

AProgrammer
  • 10,532
  • 1
  • 32
  • 48
2

Other than historical accident, there is no particular reason why we should use 8 / 16 / 32 / 64 bit. I suppose that 12 / 24 / 48 / 96 bit would really be more useful.

For handling text, Unicode using a hypothetical UTF-24 would be cheaper than UTF32; hypothetical UTF-12 would store all single and double byte UTF-8 characters in 12 bits, and all triple and quad byte UTF-8 characters in 24 bits (the range would be slightly reduced to 2^20 characters, but that's still four times more than is generously used); code would be simpler because there are only two variants.

For floating point, 48 bit is usually enough. 96 bit is substantially better than 80 bit extended. 24 bit is useful for graphics; much more useful than the 16 bit supported by some graphics cards. 48 bit pointers can handle 256 terabyte.

About the only disadvantage is bit arrays, where a division by 12 is need to calculate byte positions. If that is felt to be important, I'm sure division by 12 can be implemented quite efficiently in hardware.

gnasher729
  • 49,096
2

According to Wikipedia article for word, this makes calculations related to addressing memory significantly easier:

Different amounts of memory are used to store data values with different degrees of precision. The commonly used sizes are usually a power of two multiple of the unit of address resolution (byte or word). Converting the index of an item in an array into the address of the item then requires only a shift operation rather than a multiplication. In some cases this relationship can also avoid the use of division operations. As a result, most modern computer designs have word sizes (and other operand sizes) that are a power of two times the size of a byte.

vartec
  • 20,846
1

This is convenient due to common hardware architectures using multiples of 8, e.g. 32-bit and 64-bit architectures. This means greater efficiency when using 8-bit data storage and transmission.

"However, considerations of economy in design strongly push for one size, or a very few sizes related by multiples or fractions (submultiples) to a primary size. That preferred size becomes the word size of the architecture."

Word (computer architecture)

See also: What is the history of why bytes are eight bits?

0

Not always are word widths a power of two. I have recently been doing some coding in a SHArC DSP that has a 32-bit word width for numbers but not for the opcodes (which are 48-bits wide).

Probably the reason why word widths are a power of two is because of some instructions that test (or set or clear or toggle) a single bit or shift (or rotate) left or right by a specified number of bits. There is a bit field in the opcode to specify the location of the single bit or the number of bits to shift. If the word width is a power of two, this bit field requires log2(word_width) bits to cover the whole word. That is, a word that is 32 bits wide needs a 5-bit field in the opcode for these operations. If the word was 33 bits wide, it would need 6 otherwise it could not cover the whole word, but that would also be the case if the word was 64 bits wide.

Bits in an opcode are extremely valuable, so they don't usually wanna waste them. Then it makes sense to make the word a power of 2 wide.

The reason bytes are 8 bits wide is that it's the smallest power of two that can hold an ASCII character (which is 7 bits).

robert bristow-johnson
  • 1,190
  • 1
  • 8
  • 18
-1

It is tightly related to address space. By adding one bit more to your address bus, you can address twice as many memory locations. So when you add that extra line, you might as well use it to its full extend.

This leads to a natural progression of 1, 2, 4, 8, 16, 32 et cetera.

On a production technical level it is also easy to repeat the same lithographical pattern. That is, to double it. If you start out with one latch and then double the pattern, you will pass 8, not 6, 10 or 12.

Martin Maat
  • 18,652