IS 2063: BINARY SYSTEM
DEFINITION: The binary number system is a positional number system used by computers to manipulate, represent, and interpret data. Data comes in several forms: numbers, letters/symbols, and even images. The computer only understands bits, so data familiar to humans must be translated into bits. There are eight (8) bits to one (1) byte. It takes one byte to represent a character as seen in the ASCII character set.
In example 1 below are eight (8) positions. Each position can store either a zero (0) or a one (1), i.e., each position can hold a 1-bit or a 0-bit, hence two different bits, hence binary is called the base 2 number system. To determine which bit it is, each bit is assigned a position number from 0 through 7 ordered right to left. Since position 0 can hold one of two different bit types then the possible combination for that position is 20. Since position 1 can hold one of two different bit types the possible combination for that position in conjunction with position 0 is 21, etc.
Example 1:
1 possible combinations for 20 = 1
1 0
1 1 possible combinations for 21 = 2
1 0 0
1 0 1
1 1 0 possible combinations for 22 = 4
1 1 1
_ _ _ _ _ _ _ _
27 26 25 24 23 22 21 20
USAGE: The 1-bit is the on-bit. Every position that has a 1-bit gets interpreted to its decimal form so that all the bits are translated into a number of the base 10 number system that is familiar to humans. Therefore each binary value has its decimal counterpart. Each decimal counterpart is assigned a character which is either a letter or special symbol. Consequently the computer will know which letter or symbol it is dealing with in the form of one (1) byte.
Example 2:Below is a representation of the capital letter “J”. As this letter is typed, the typist sees the capital letter “J”, but the computer sees the string of 1s below.
0 1 0 0 1 0 1 0
27 26 25 24 23 22 21 20
64 8 2 = 74
(decimal number)
assigned to capital letter “J”
The above byte represents a character that is non-numeric. A character that looks like a number may not be a mathematical number even if it has a binary value assigned to it.
Example 3:The digit “2” is the 51st character listed in the ASCII character set.
0 0 1 1 0 0 1 0
27 26 25 24 23 22 21 20
32 16 2 = 50
(decimal number)
assigned to the
non-numeric “2”
The computer knows whether a character is numeric or non-numeric based on how it is told to treat the character through what are called data types. Think about the cells in a spreadsheet package such as Microsoft Excel. Cells that are used in calculations are typed as numbers and those that are not are typed as text. Similarly in programming a variable (sometimes referred to as a field or identifier) is given a data type, so that whatever is stored in the variable has to match the data type for the variable. A variable that is typed as a character can only store a single character such as a letter or symbol. A variable typed as an integer can store numbers but only whole numbers. A variable typed as a double can store numbers such as real numbers or ones able to hold fractions. A variable typed as a String can store more than one character. Therefore, if a variable is typed as a character and it stores 3, then the binary value is 00110011 (or the decimal number 51). But what if the variable is typed as an integer? It will have to store the 3 as a real number.
Example 4:The binary value for a numeric 3 stores a 1-bit in the positions that will translate it into a decimal 3.
0 0 0 0 0 0 1 1
27 26 25 24 23 22 21 20
2 1 = 3 (decimal number)
ARITHMETICS: To arithmetically manipulate values in an equation or calculation, the values have to be algebraic (i.e., countable or computable) so that two binary values can be added and produce the same result as their decimal counterpart.
Example 5:
Binary Value Decimal Counterpart
27 26 25 24 23 22 21 20
8 4 2 1
0 0 0 0 0 0 1 1 3
+0 0 0 0 0 1 1 1 +7
0 0 0 0 1 0 1 0 10
CONVERTING DECIMAL TO BINARY: To convert a decimal number to a binary number requires successive division of the decimal number by 2 until the quotient is zero (0). Look at the conversion for the decimal number 152.
Example 6: 76, 38, 19, etc. are the quotients.
152/2 = 76 with a remainder of 0
76/2 = 38 with a remainder of 0
38/2 = 19 with a remainder of 0
|
19/2 = 9 with a remainder of 1
9/2 = 4 with a remainder of 1
4/2 = 2 with a remainder of 0
2/2 = 1 with a remainder of 0
½ = 0 with a remainder of 1
NOTE: Decimal numbers beyond 255 require more than 8 bits.
EXERCISE: Convert every value indicated from a decimal or a word to binary or binary to a decimal or a word. This includes any calculated values (solve the equations). Save the completed exercise as YourLastNameFirstInitialBinary.docx and upload to Blackboard via Assignments. Make sure to erase the first 3 pages.
DECIMAL/WORD | BINARY |
100110001 | |
421 | |
1111011 | |
171 | |
110100110 | |
+_________ | 10011000
+10101011
|
115 | |
25
+282
|
+_________ |
+_________ | 11010111
+00111011
|
305
+210
|
+_________ |
Dog | |
01000100 01001111 01000111 |