Numbering Systems Notes

Converting Fractions

  • To convert a fractional decimal value to binary, repeatedly multiply the decimal fraction by 2.

    • Example: Convert 11.375 to binary.
      • First, convert 11 to binary: 11<em>10=1011</em>211<em>{10} = 1011</em>2
      • Then, convert 0.375 to binary:
        • 0.375 * 2 = 0.750 --> 0
        • 0.750 * 2 = 1.500 --> 1
        • 0.500 * 2 = 1.000 --> 1
        • Therefore, .375<em>10=.011</em>2.375<em>{10} = .011</em>2
      • Finally, 11.375<em>10=1011.011</em>211.375<em>{10} = 1011.011</em>2
  • Exercise:

    • Convert the following numbers to their binary equivalents. <br/>(26.75<em>10)=11010.11</em>2<br /> (26.75<em>{10} ) = 11010.11</em>2
      <br/>(37.37510)=?<br /> (37.375_{10} ) = ?
  • Exercise:

    • Convert the following decimal number to binary? (0.2)<em>10=(0.0011)</em>2(0.2)<em>{10} = (0.0011)</em>2
    • (0.3)<em>10=(0.01001)</em>2(0.3)<em>{10} = (0.01001)</em>2

Adding Binary Fractions

  • To add binary fractions, align the decimal points and add as usual.

    • Example:

    ```
    1011.0

  • 0.011

    1011.011
    ```

  • Example:

    ```
    1
    110.01

  • 1.011
    --------
    111.101
    ```

Binary Subtraction

  • Use 2's complement representation for subtraction.
    • Rewrite ABA-B as A+(B)A + (-B)
    • Example: Solve 01111111<em>276</em>10=???01111111<em>2 – 76</em>{10} = ???
      • Rewrite as 01111111<em>2+(76)</em>1001111111<em>2 + (– 76)</em>{10}
      • Convert 76 to binary: 76<em>10=01001100</em>276<em>{10} = 01001100</em>2
      • Find the 1's complement: 1011001110110011
      • Find the 2's complement by adding 1: 10110011+1=1011010010110011 + 1 = 10110100
      • (76)<em>10=10110100</em>2(– 76)<em>{10} = 10110100</em>2
      • Add the numbers:
  1 1
    01111111
+    10110100
    ---------
  1 00110011
    ```
        *   011111112+(76)10=00110011201111111_2 + (– 76)_{10} = 00110011_2
*   127 - 76 = 51

*   When computing, if the carry bit exists this represents overflow.

*   Example: 001100102+(125)1000110010_2 + (– 125)_{10}
    *   12510=011111012125_{10} = 01111101_2
    *   1's complement: 1000001010000010
    *   2's complement: 1000001110000011
00110010
  • 10000011 --------- 10110101 ```
    • 50125=7550-125=-75
    • The 2’s comp for the result (10110101) is 01001011 equivalent to (75) 10

Data Representation

  • Computers understand on and off states.
  • Data is represented in binary form.
  • Bit: The basic unit for storing data (0 = off, 1 = on).
  • Byte: A group of 8 bits. Each byte has 28=2562^8 = 256 possible values.
  • Word: Two bytes (16 bits).

Parity Bit

  • Used for error detection.
    • Odd parity: The number of 1s is odd.
    • Even parity: The number of 1s is even.

Characters Representation

  • ASCII (American Standard Code for Information Interchange) is used to represent characters.
    • A = 65, B = 66, …, a = 97, b = 98, …
Example using Even Parity
  • Represent the character Q (81 in ASCII) in memory using even parity.
    • (81)<em>10=(01010001)</em>2(81)<em>{10} = (01010001)</em>2
    • With even parity: D1 (hexadecimal)
Example using Odd Parity
  • Represent letters using odd parity:
    • A 01000001
    • h 01101000
    • m 01101101

Integers Representation

  • Representing integers in memory using 2 bytes.
    • Example: Represent 92
      • 92=101110092 = 1011100
      • 0000 0000 01011100
      • 0 0 5 C
    • Example: Represent -94
      • 94=000000000101111094 = 0000000001011110
      • 1’s complement-> 1111111110100001
      • 2’s complement-> 1111111110100010
      • F F A 2

Floating Point Representation

  • 32 bits are divided into three sections: sign, exponent, and mantissa.

    • 1 bit for sign (0 for positive, 1 for negative).
    • 8 bits for exponent.
    • 23 bits for mantissa.
  • For the exponent:

    • Range: 0-255. To represent negative exponents, a bias is used.
    • Bias = 127 (integer part of 255/2 = 127.5).
    • So, the exponent range is -127 to 128.
  • Example: Represent (26.75)10 using 32-bit floating-point representation.

    • Convert to binary: (26.75)<em>10=(11010.11)</em>2(26.75)<em>{10} = (11010.11)</em>2
    • Convert to scientific notation: (11010.11)<em>2=(1.10101124)</em>2(11010.11)<em>2 = (1.101011 * 2^4)</em>2
    • Exponent = 127 + 4 = 131. Convert to binary: (131)<em>10=(10000011)</em>2(131)<em>{10} = (10000011)</em>2
    • Final representation:
      • 0 10000011 10101100000000000000000
      • 4 1 D 6 0 0 0 0