Binary System

Fundamental Concepts of Binary

  • Binary is the primary language used by computers to communicate and process information.
  • It is a numerical system that uses only two digits: 00 and 11.
  • These digits are used to represent all numerical values and characters within a computer system.

The Decimal System (Base 10)

  • In everyday life, we use the decimal system, which is based on the number 1010.
  • This system utilizes ten digits: 0,1,2,3,4,5,6,7,8, and 90, 1, 2, 3, 4, 5, 6, 7, 8, \text{ and } 9.
  • Positional Value (HTU): The value of a digit is determined by its position.
    • H (Hundreds): The third position from the right.
    • T (Tens): The second position from the right.
    • U (Units/Ones): The first position from the right.
  • Example: In the number 569569, the digit 55 actually represents five hundreds (500500) because there are two whole numbers to its right.
  • Base 10 Logic: Each position to the left is worth 10×10 \times more than the place to its immediate right.
    • 100101100 \leftarrow 10 \leftarrow 1
    • The progression follows: 1×10=101 \times 10 = 10, and 10×10=10010 \times 10 = 100.

The Binary System (Base 2)

  • Binary is known as 'Base 2' because it utilizes two digits.
  • Base 2 Logic: Each position to the left is worth 2×2 \times more than the place to its immediate right.
  • The column values increase by powers of two:
    • 16,8,4,2,116, 8, 4, 2, 1
    • The progression follows: 1×2=21 \times 2 = 2, 2×2=42 \times 2 = 4, 4×2=84 \times 2 = 8, and 8×2=168 \times 2 = 16.
  • While manually identifying columns (like HTU in decimal), one should remember these values (1,2,4,8,161, 2, 4, 8, 16 \dots) to perform conversions efficiently.

Converting Decimal to Binary

  • Writing numbers in binary involves identifying which column values, when added together, equal the desired decimal number.

  • Binary Rule: You may only use the digits 00 (off/unused) and 11 (on/used).

  • Demonstration with Binary-Bot: To write the number 99 as a binary number:

    • Look at the columns: 16,8,4,2,116, 8, 4, 2, 1.
    • The highest value within 99 is 88, so put a 11 in the 88 column.
    • There is 11 remaining (98=19 - 8 = 1).
    • Put a 00 in the 44 column and the 22 column.
    • Put a 11 in the 11 column.
    • Calculation: (1×8)+(1×1)=9(1 \times 8) + (1 \times 1) = 9.
    • Result: 10011001.
  • Prohibited Methods: One cannot represent 99 using other digits or improper formatting (as queried by the interlocutor):

    • You cannot use a 44 in the column (e.g., placing the digit 44 and a 11 in the table) or use multiple instances of a number like (1×4)+(2×2)+(1×1)(1 \times 4) + (2 \times 2) + (1 \times 1) because binary only allows the digits 00 and 11.
  • Further Examples of Conversions:

    • 10: 32(0),16(0),8(1),4(0),2(1),1(0)101032(0), 16(0), 8(1), 4(0), 2(1), 1(0) \rightarrow 1010
    • 18: 32(0),16(1),8(0),4(0),2(1),1(0)1001032(0), 16(1), 8(0), 4(0), 2(1), 1(0) \rightarrow 10010
    • 33: 32(1),16(0),8(0),4(0),2(0),1(1)10000132(1), 16(0), 8(0), 4(0), 2(0), 1(1) \rightarrow 100001

Binary Addition Rules and Operations

  • Binary addition follows specific rules because only two digits are available (00 and 11). This differs from standard decimal addition.

  • Operation Rules:

    • 0+0=00 + 0 = 0
    • 0+1=10 + 1 = 1
    • 1+0=11 + 0 = 1
    • 1+1=0 (with 1 carried over to the next higher column)1 + 1 = 0 \text{ (with } 1 \text{ carried over to the next higher column)}
    • 1+1+1=1 (with 1 carried over to the next higher column)1 + 1 + 1 = 1 \text{ (with } 1 \text{ carried over to the next higher column)}
  • Worked Example Calculation:

    • Term 1: 0101110101011101
    • Term 2: 0011001000110010
    • Sum: 1000111110001111

Exercises and Odd Number Identification

  • To determine if a binary number is odd, look at the '1's column (the far-right bit). If the far-right bit is a 11, the number is odd; if it is a 00, the number is even.
  • Practice Conversions (Question to Answers):
    • 10111=1110111 = 11
    • 10001=1710001 = 17
    • 10110=2210110 = 22
    • 10=210 = 2
    • 111111=63111111 = 63
    • 101010=42101010 = 42
    • 10111=2310111 = 23

ASCII (American Standard Code for Information Interchange)

  • Computers use the ASCII table to map digital numbers to human-readable characters like letters and symbols.

  • Alphabet ASCII Subset (Uppercase):

    • 65=A65 = A
    • 66=B66 = B
    • 67=C67 = C
    • 68=D68 = D
    • 69=E69 = E
    • 70=F70 = F
    • 71=G71 = G
    • 72=H72 = H
    • 73=I73 = I
    • 74=J74 = J
    • 75=K75 = K
    • 76=L76 = L
    • 77=M77 = M
    • 78=N78 = N
    • 79=O79 = O
    • 80=P80 = P
    • 81=Q81 = Q
    • 82=R82 = R
    • 83=S83 = S
    • 84=T84 = T
    • 85=U85 = U
    • 86=V86 = V
    • 87=W87 = W
    • 88=X88 = X
    • 89=Y89 = Y
    • 90=Z90 = Z
  • Miscellaneous ASCII Codes (Selected):

    • Digits: 48=048 = 0, 49=149 = 1, 50=250 = 2, 51=351 = 3, 52=452 = 4, 53=553 = 5, 54=654 = 6, 55=755 = 7, 56=856 = 8, 57=957 = 9
    • Lowercase: 97=a97 = a, 98=b98 = b, 99=c99 = c, 100=d122=z100 = d \dots 122 = z
    • Symbols: 33=!33 = !, 34="34 = ", 35=#35 = \#, 36 = \, 37=%37 = \%, 38=&38 = \&, 40=(40 = (, 41=)41 = ), 43=+43 = +, 44=,44 = ,, 45=45 = -, 46=.46 = ., 47=/47 = /, 58=:58 = :, 59=;59 = ;, 60=<60 = <, 61==61 = =, 62=>62 = >, 63=?63 = ?, 64=@64 = @, 91=[91 = [, 92=\92 = \backslash, 93=]93 = ], 123={123 = \{, 124=124 = |, 125=}125 = \}, 127=DEL127 = \text{DEL}.

Application: Encoding Names in Binary

  • To translate a name like Erick Singh, you must find the decimal value for each character in the ASCII table and convert that decimal into binary.

  • Name Breakdown:

    • E: Decimal 6969 | Binary: 0100010101000101
    • r: Decimal 114114 | Binary: 0111001001110010
    • i: Decimal 105105 | Binary: 0110100101101001
    • c: Decimal 9999 | Binary: 0110001101100011
    • k: Decimal 107107 | Binary: 0110101101101011
    • S: Decimal 8383 | Binary: 0101001101010011
    • i: Decimal 105105 | Binary: 0110100101101001
    • n: Decimal 110110 | Binary: 0110111001101110
    • g: Decimal 103103 | Binary: 0110011101100111
    • h: Decimal 104104 | Binary: 0110100001101000
  • Binary Mapping Grid (Reference):

    • Columns: 128,64,32,16,8,4,2,1128, 64, 32, 16, 8, 4, 2, 1
    • Example (E = 69): 0×128+1×64+0×32+0×16+0×8+1×4+0×2+1×1=690 \times 128 + 1 \times 64 + 0 \times 32 + 0 \times 16 + 0 \times 8 + 1 \times 4 + 0 \times 2 + 1 \times 1 = 69

Questions & Discussion

  • Question from Student: "But couldn’t I get to 9 like this, Binary-Bot? [Using decimals 4 and 1 in the grid] Or like this? [1x4 and 2x2 and 1x1]?"
  • Binary-Bot Response: "No! Binary only uses 1s and 0s."