Byte

A byte is a unit of digital data that encodes information on a computer such as letters, numbers, and pixels of color.

A byte typically contains a series of 8 bits. Each bit is represented using the binary digits 0 or 1. For example the following byte, containing the bits 00101100, has a value of 44 in the decimal numeral system. To better understand how to find what a given byte represents, it is necessary to understand how the binary numeral system works.

Binary numeral system

The binary numeral system is a base-2 positional numeral system, rather than the base-10 system that most of us are accustomed to. The binary numeral system only uses two digits, 1 or 0, to represent numbers, as opposed to the decimal numeral system which uses the 10 digits 0-9. The value of a digit in a positional numeral system is determined by the base (e.g. 2 for binary, 10 for decimal, etc), the place value of a given digit, and the actual digit. For example, in the decimal numeral system, also referred to as the base-10 numeral system, 831,045 can be expanded as follows:


 
 

In the example above, each digit has a place value of 10 to some power, which corresponds to the position of the digit within the number. As we move left in the number, each place value increases by 10 times, and the place value can be determined by the position of the digit relative to the decimal point. Thus, the 1st digit left of the decimal point has a place value of 100, the 2nd has a place value of 101, the 3rd has a place value of 102, and so on. In the example above, "831,045" could also have been written as "831,045." which enables us to determine the place value of each digit, as depicted in the place value chart below:


  Place value
Hundred-thousands Ten-thousands Thousands Hundreds Tens Ones (units)
Power 105 104 103 102 101 100
Digit 8 3 1 0 4 5

The binary numeral system works in a similar manner, except that the only digits used are 0 and 1, and the base is 2. Consider the following place value chart as well as the binary number 10001001:


  Place value
One hundred twenty-eights Sixty-fours Thirty-twos Sixteens Eights Fours Twos Ones (units)
Power 27 26 25 24 23 22 21 20
Digit 1 0 0 0 1 0 0 1

Expanding the number above as we did with the number in the decimal numeral system above,


 
 
 
 

10001001 in the binary numeral system is equivalent to 137 in the decimal numeral system.

Examples

Convert the following binary numbers to decimal numbers.

i. 10100:


 
 
 
 

ii. 10101101:


 
 
 
 

In the above example (ii.), the binary number contains eight digits consisting of either a 0 or a 1; these digits are the eight bits that form a byte. A byte ranges from 00000000 to 11111111, or in decimal form, 0 to 255. There are therefore 256 possible arrangements (including 0) that can be made with the eight digits contained in a byte. When a computer processes a byte to a character that is a letter, piece of text, color, etc., the binary number that represents the byte is converted to decimal form. The computer then identifies the decimal number from a list of decimal numbers called the American Standard Code for Information Interexchange (ASCII), which are associated with the character displayed on a computer's monitor.

For example, the ASCII code for the byte 01000001 is:


 
 
 
 

The ASCII code associated with the number 65 is the letter A, and this is the output that would be displayed on the computer. Below is a table of ASCII codes and their corresponding values:



A byte represents only one character. To display something like a word, multiple bytes need to be converted to ASCII code. For example, the three bytes, 01100011, 01100001, and 01110100 correspond to the word "cat."

We can also convert the ASCII code to a binary code using the reverse of the process above. Start with a series of divisions by 2 of the given ASCII code and use the remainders to form the binary number. For example, 37 can be converted to binary form as depicted in the table below:


Iterations of division by 2 Remainder Binary number
37/2 = 18 1 1
18/2 0 01
9/2 = 4 1 101
4/2 = 2 0 0101
2/2 = 1 0 00101
1/2 = 0 1 100101

In the table above, each remainder for the iterations of division by 2 is listed to the left of the previous remainder to form the binary number. The process of division continues until the quotient is 0. In order for a given binary number to be written as a byte, there must be 8 bits. Placing two 0's in front of the binary number allows us to form a byte: 00100101.

File size

As can be seen from above, it takes an immense number of bytes to create a text document; it takes even more to create images and videos. A file or disk drive on a computer uses prefixes to identify their size in bytes. For example, one kilobyte is equivalent to 1000 bytes since "kilo-" is a metric prefix that indicates 1000. In reality however, one kilobyte is equivalent to 1000 bytes since computers use the base 2 system (210 = 1024). The table below shows the number of bytes in various units of data storage:


Unit Size in bytes Examples
Byte (B) 1 Letter of the alphabet
Kilobyte (KB) 210 = 1024 Email with a few sentences and no images
Megabyte (MB) 220 = 1,048,576
or 1024 KB
Images
Gigabyte (GB) 230 = 1,073,741,824
or 1024 MB
Computer RAM
Terabyte (TB) 230 = 1,099,511,627,776
or 1024 MB
Hard drive of a computer