ðŸ¥ª Summary
- A “Byte” is a grouping of 8 “bits“.
- Some counts start at zero.
- Set of Eight = { 0, 1, 2, 3, 4, 5, 6, 7 }
- A grouping of 8 is known as an ðŸ¦‘ octet.
- 8 bits can represent number sets { 0 … 255 } and { (-128) … 127 }.
- ASCII Encoding is an interpretation of the number set { 0 … 255 }.
- Bit groupings are known as blocks.
- Endianness is interpretation, most to least significant bit, or least to most significant bit, either big-endian or little-endian.
A Byte
A byte is 8 bits, or an ‘octave’ or ‘octal‘ grouping of bits.
When all you have to work with are two switches that are either on or off, the best you can do is to group them.
Bit Groupings | ||
4-bits | Â½ Byte / Nibble / Half Octet | |
8-bits | Byte / Octet |
Start At Zero
In computer science, we sometimes consider zero ‘0’ to be the first item of any grouping.
Three Sets of Three
{ 0, 1, 2 },Â { A, B, C },Â { Î±, Î², Î³ }
Four Different Numbering Systems | ||||||||
Binary | 2^{7} | 2^{6} | 2^{5} | 2^{4} | 2^{3} | 2^{2} | 2^{1} | 2^{0} |
Â { 0, 1 } | 0 | 1 | 1 | 0 | 1 | 1 | 1 | 1 |
Octal | 8^{7} | 8^{6} | 8^{5} | 8^{4} | 8^{3} | 8^{2} | 8^{1} | 8^{0} |
Â { 0 … 7 } | 1 | 5 | 7 | |||||
Decimal | 10^{7} | 10^{6} | 10^{5} | 10^{4} | 10^{3} | 10^{2} | 10^{1} | 10^{0} |
Â { 0 … 9 } | 1 | 1 | 1 | |||||
Hexadecimal | 16^{7} | 16^{6} | 16^{5} | 16^{4} | 16^{3} | 16^{2} | 16^{1} | 16^{0} |
Â { 0 … 9, A … F } | 6 | F |
ASCII Encoding
ASCII Encoding is based on the number set defined by groupings of eight bits, and we can interpret the grouping above as the letter “o”.
Base II |
Base VIII |
Base X |
Base XVI |
ASCII |
01101110 | 156 | 110 | 6E | n |
01101111 | 157 | 111 | 6F | o |
01110000 | 158 | 112 | 70 | p |
Extended ASCII
Grouping Limits
Binary uses only two digits, 0, and 1, to represent certain sets of numbers. The sets are limited by the number of bits the system was designed to accomodate.
An 8-bit system, or a system that has 8-bit architecture, can accomodate numbers between 0 and 255.
8-bits = { 0 … 255 }
If you wanted to use one bit as a sign to distinguish between negative and positive integers, the range would change to -128 to +127.
8-bits signed = { (-128) … 127 }
Â Â Â Â Â Â 127_{10}
Signed and Unsigned | ||||||||
---|---|---|---|---|---|---|---|---|
Unsigned | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0_{ 2} |
0_{ 10} | ||||||||
1 | 1 | 1 | 1 | 1 | 1 | 1 | 1_{ 2} | |
2 | 5 | 5_{ 10} | ||||||
There are three methods of representing negative numbers in binary. The first and most plain is to use one bit as an indicator of signage. If the bit is 1, the number may be positive. If the bit is 0, the number may be negative, or vise-versa.
Two more methods include 1s Compliment, and 2s Compliment.
1s Compliment
Invert the digits, as in 1s go to 0, and 0s go to 1. Use the leading bit to indicate singage, then flip the remaining digits back to decipher the positive or negative value. This method is used with the bitwise operator ^.
2s Compliment
Flip the bits as in 1s compliment, this time adding a value of one to the flipped value.
These groupings of bits are known also as blocks. Every byte of the system belongs to a specific, numbered block. These numbers are commonly referred to as “pointers”.
Pointers are numbered bytes. Pointers are usually represented as hexadecimal numbers, as byte quantities can become very large.
0x00000000 is the very first element of a 32-bit number space, in this case represented as a hexadecimal digit. The “0x” preceeding the alphanumeric sequence denotes that this is hexidecimal notation.
0xFFFFFFFF is the last element of the 32-bit number space.
4,294,967,295 individual bytes.
34,359,738,360 individual bits.
Endianness
Endianness is another distinction between systems. It refers to the idea of which direction the information is read/written to, ie. left to right, right to left, front to back, back to front, most significant bit to least significant bit, least to most; A binary choice the systems designer must make in the early stages.
The two methods are known and big-endian, from most to least significant bit, and little-endian, least to most significant bit.
The least significant bit is analogous to the right-most integer in base 10 notation, in the style of the Western conventions.
The least significant bit is that which distinguishes the value as being either even or odd.
Endianness | ||||||||
Big-Endian | x^{7} | x^{6} | x^{5} | x^{4} | x^{3} | x^{2} | x^{1} | x^{0} |
Little-Endian | x^{0} | x^{1} | x^{2} | x^{3} | x^{4} | x^{5} | x^{6} | x^{7} |