Number System Mep

Embed Size (px)

Citation preview

  • 8/4/2019 Number System Mep

    1/61

    NUMBER SYSTEM & COMPUTER

    ARITHMETIC

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    2/61

    Objectives

    Learn the following Positional Number system

    Different number system

    Conversion of number system Fractional numbers

    Computer arithmethic

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    3/61

    Positional Number system

    based on exactly where the numbers are in thesequence of numbers

    A number is represented by a string of digits

    where each digit position has an associated

    weight.

    The value of each digit in such a number isdetermined by three considerations:

    1. The digit itself,

    2. The position of the digit in the number, and

    3. The base of the number system.

    CS 211 COMPUTER FUN DAMENTALS

  • 8/4/2019 Number System Mep

    4/61

    Decimal (base 10) numbers are expressed in thepositional notation

    4202 = 2x100 + 0x101 + 2x102 + 4x103

    The right-most is the least significant digit

    The left-most is the most significant digit

    Positional Number system

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    5/61

    4202 = 2x100 + 0x101 + 2x102 + 4x103

    1s multiplier

    1

    Decimal (base 10) numbers are expressed in thepositional notation

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    6/61

    4202 = 2x100 + 0x101 + 2x102 + 4x103

    10s multiplier

    10

    Decimal (base 10) numbers are expressed in thepositional notation

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    7/61

    4202 = 2x100 + 0x101 + 2x102 + 4x103

    100s multiplier

    100

    Decimal (base 10) numbers are expressed in thepositional notation

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    8/61

    4202 = 2x100 + 0x101 + 2x102 + 4x103

    1000s multiplier

    1000

    Decimal (base 10) numbers are expressed in thepositional notation

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    9/61

    Binary (base 2) numbers are alsoexpressed in the positional notation

    10011 = 1x20 +1x21 +0x22 +0x23 +1x24

    The right-most is the least significant digit

    The left-most is the most significant digit

    CS 211 COMPUTER FUN DAMENTALS

  • 8/4/2019 Number System Mep

    10/61

    10011 = 1x20 +1x21 +0x22 +0x23 +1x24

    1s multiplier

    1

    Binary (base 2) numbers are alsoexpressed in the positional notation

    CS 211 COMPUTER FUN DAMENTALS

  • 8/4/2019 Number System Mep

    11/61

    10011=1x20 + 1x21 +0x22 +0x23 +1x24

    2s multiplier

    2

    Binary (base 2) numbers are alsoexpressed in the positional notation

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    12/61

    10011=1x20 +1x21 + 0x22 +0x23 +1x24

    4s multiplier

    4

    Binary (base 2) numbers are alsoexpressed in the positional notation

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    13/61

    10011=1x20 +1x21 +0x22 + 0x23 +1x24

    8s multiplier

    8

    Binary (base 2) numbers are alsoexpressed in the positional notation

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    14/61

    10011 = 1x20 +1x21 +0x22 +0x23 + 1x24

    16s multiplier

    16

    Binary (base 2) numbers are alsoexpressed in the positional notation

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    15/61

    Counting in

    Decimal

    0

    1

    23

    4

    5

    6

    7

    8

    9

    10

    11

    1213

    14

    15

    16

    17

    18

    19

    20

    21

    2223

    24

    25

    26

    27

    28

    29

    30

    31

    3233

    34

    35

    36

    .

    .

    .

    0

    1

    1011

    100

    101

    110

    111

    1000

    1001

    1010

    1011

    11001101

    1110

    1111

    10000

    10001

    10010

    10011

    10100

    10101

    1011010111

    11000

    11001

    11010

    11011

    11100

    11101

    11110

    11111

    100000100001

    100010

    100011

    100100

    .

    .

    .

    Counting

    in Binary

    CS 211 COMPUTER FUN DAMENTALS

  • 8/4/2019 Number System Mep

    16/61

    Number system

    A number system uses a specific radix (base) e.g. Decimal base 10

    Binary base 2

    In digital electronics (computer) the only choice of

    base in which to perform arithmetic is base-2, that isbinary arithmetic, using the only two digits available, 0and 1.

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    17/61

    Decimal number system

    uses the common 0 thru 9 digits Single-digit numbers 0 to 9 make up the set numbers

    called units or ones

    When the count is higher than 9 the number is carried

    over to what is called the tens position

    If the number is over 99 the carried over number is in thehundreds position.

    After the hundreds the position are thousands, ten

    thousands, hundred thousand, millions, etc.

    Each position, or place value, to the left increases by afactor of 10.

    Thus, the decimal number system is the base 10 system

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    18/61

    Binary Number System

    Also called the Base 2 systemThe binary number system is used to

    model the series of electrical signals

    computers use to represent information0 represents the no voltage or an off state

    1 represents the presence of voltage or an

    on state known as machine language

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    19/61

    Binary Digit (Bit)

    A bit (binary digit) is the smallest unit of information

    can have two values - 1 and 0.

    Binary digits, or bits, can representnumbers, codes, or instructions.

    Byte: a grouping of eight bits of

    information

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    20/61

    Binary Number SystemThe names of the first few places in the binary notation are:

    16s 8s 4s 2s 1s

    (the places are powers of two):

    2

    x

    2 2

    x x

    2 2 2

    x x x

    2 2 2 2 1

    16s 8s 4s 2s 1s

    Each place is double the last place from the right to left

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    21/61

    Octal Number System

    Also known as the Base 8 SystemUses digits 0 - 7

    Readily converts to binary

    Groups of three (binary) digits can beused to represent each octal digit

    Also uses multiplication and division

    algorithms for conversion to and from base10

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    22/61

    Hexadecimal Number System

    Base 16 system

    Uses digits 0-9 &

    letters A,B,C,D,E,F

    Groups of four bits

    represent eachbase 16 digit

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    23/61

    Integer Representation

    Use 8, 16, 32 or 64 bit to represent number usingpositional notation

    Unsigned -- 10101010=170

    Cant represent negative numbers

    Simple

    8 bit unsigned integer from 0 to 255

    Signed -- 10101010= -42

    The most significant bit of a binary number is usuallyused as the sign bit.

    Uses MSB for sign 1 = - , 0 = +

    computers do not subtract very well

    8 bit signed integer from 127 to 128

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    24/61

    (4bit)Signed numbers

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    25/61

    1s compliment & 2s complement used torepresent positive and negative number

    Allows the computer to use addition to

    deal with subtraction

    Integer Representation

    1s complement

    5 00000101

    -5 11111010

    2s complement

    5 00000101

    -5 11111010 + 1 = 11111010CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    26/61

    Fractional numbers (Floating point Representation)

    single precision binary floating-pointformat ( binary32)

    Sign bit: 1 bit (1 negative, 0 positive)

    Exponent: width: 8 bitsSignificand precision(mantissa): 23

    (IEEE 754 single precision binary floating-point format)

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    27/61

    Binary Code

    A digital system requires that all its information be inbinary form. But the External world uses the alphabetic

    characters, decimal digits, and special Characters (e.g.,

    periods, commas, plus and minus signs) to represent

    information.

    A unique pattern of 0s and 1s is used to represent eachrequired character. This pattern is the code

    corresponding to that character.

    several codes that are commonly used in digital

    systems. Binary Coded Decimal

    Alphanumeric Codes

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    28/61

    Binary Coded Decimal

    Each Decimal digit is coded into 4 bits

    DECIMAL BCD

    0 0000 5 0101

    1 0001 6 0110

    2 0010 7 01113 0011 8 1000

    4 0100 9 1001

    Only ten of the possible sixteen (24) patterns of bits are

    used.e.g. 43210 would represented as:

    0100 0011 0010

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    29/61

    Alphanumeric Codes

    Extended BCD Interchange Code (EBCDIC)

    American Standard Code for Information Interchange (ASCII).

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    30/61

    NUMBER SYSTEM

    CONVERSION

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    31/61

    Decimal to Binary Conversion

    The easiest way to convert a decimal number to itsbinary equivalent is to use the Division Algorithm

    This method repeatedly divides a decimal number by 2

    and records the quotient and remainder (stop whenquotient is zero)

    The remainder digits (a sequence of zeros and ones)

    form the binary equivalent.

    The first remainder is the least significant digit(LSD),and

    the last Remainder is the most significant digit(MSD).

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    32/61

    Decimal to Binary ConversionConvert decimal number 2810 into binary.

    28/2 = 14 0 (LSD)

    14/2 = 7 0

    7/2 = 3 1

    3/2 = 1 1

    1/2 = 0 1 (MSD)

    The Binary number is 111002

    Convert decimal number 12210 into binary.

    122/2 = 61 0 (LSD)

    61/2 = 30 1

    30/2 = 15 0

    15/2 = 7 1

    7/2 = 3 1

    3/2 = 1 1

    1/2 = 0 1 (MSD)

    The Binary number is 11110102 CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    33/61

    Binary to Decimal Conversion

    The easiest method for converting abinary number to its decimal equivalent isto use the Multiplication Algorithm

    Multiply the binary digits by increasingpowers of two, starting from the right

    Then, to find the decimal number

    equivalent, sum those products

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    34/61

    Convert binary number 111002 into decimal.

    1 1 1 0 0

    1 x 24 = 16 1 x 23 = 8 1 x 22 = 4 0 x 21 = 0 0 x 20 =0

    16 + 8 + 4 = 2810

    Binary to Decimal Conversion

    Convert binary number 11110102 into decimal.

    1 1 1 1 0 1 0

    1 x 26 =64

    1 x 25 =32

    1 x 24 =16

    1 x 23 =8

    0 x 22 =0

    1 x 21 =2

    0 x 20

    =0

    64 + 32 + 16 + 8 + 2 = 12210

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    35/61

    To convert a decimal number into hexadecimal,divide the number repeatedly by 16 and takethe remainders. The first remainder is the LSD,and the last remainder is the MSD.

    Decimal to Hexadecimal Conversion

    Convert Decimal number 68410 into Hexadecimal.C (LSD)

    A

    2 (MSD)

    The Hexadecimal number is 2AC16

    Convert Decimal number 83010 into Hexadecimal.

    E (LSD)3

    3 (MSD)

    The Hexadecimal number is 33E16

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    36/61

    To convert a decimal number into octal, divide thenumber repeatedly by 8 and take the remainders.

    The first remainder is the LSD, and the last remainder is

    the MSD.

    Decimal to Octal Conversion

    Convert Decimal number 15910 into Octal.

    159/8 = 19 7 7 (LSD)

    19/8 = 2 3 3

    2/0 = 0 2 2 (MSD)

    The Hexadecimal number is 2378

    Convert Decimal number 46010 into Octal.

    460/8 = 57 4 4 (LSD)

    57/8 = 7 1 1

    7/0 = 0 7 7 (MSD)

    The Hexadecimal number is 7148

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    37/61

    Binary to Hexadecimal Conversion

    To convert a binary number into hexadecimal, arrangethe number in groups of four and find the hexadecimal

    equivalent of each group (use a substitution code).

    If the number cannot be divided exactly into groups offour, insert zeros to the left of the number as needed so

    the number of Digits are divisible by four.

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    38/61

    Binary to Hexadecimal Conversion

    Each hex number converts to 4 binary digitsConvert binary number 100111112 into decimal.

    1001 1111

    1 0 0 1 1 1 1 1

    1 x 23

    = 8 0 x 22

    = 0 0 x 21

    = 0 1 x 20

    = 1 1 x 23

    = 8 1 x 22

    = 4 1 x 21

    = 2 1 x 20

    = 1

    8 + 1 = 910 = 9 8 + 4 + 2 + 1 = 1510 = F

    100111112 = 9F16

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    39/61

    Convert 0101011010101110011010102 to hexusing the 4-bit substitution code :

    1010

    Binary to Hexadecimal Conversion

    0101 0110 1010 1110 0110

    5 6 A E 6 A

    56AE6A16

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    40/61

    Substitution code can also be used to convertbinary to octal by using 3-bit groupings:

    Convert binary 010101101010111001101010

    255271528

    Binary to Octal Conversion

    010 101 101 010111 001

    101 010

    2 5 5 2 7 1 5 2

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    41/61

    To convert an octal number into binary,write the 3-bit binary equivalent of each

    octal digit

    Octal to Binary Conversion

    convert 758 to binary7 5

    111 101

    The Binary number is 1111012

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    42/61

    To convert an octal number into binary,write the 3-bit binary equivalent of each

    octal digit

    Octal to Binary Conversion

    convert 758 to binary7 5

    111 101

    The Binary number is 1111012

    convert 6538 to binary6 5 3

    110 101 011

    The Binary number is 1101010112CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    43/61

    Octal to Decimal Conversion

    To convert an octal number into decimal, calculatethe sum of the powers of 8 of the number.

    Convert 6538 to itsdecimal equivalent:

    6 5 3

    6 x 82 =384

    5 x 81 =40

    3 x 80 =3

    384 + 40 + 3 = 427

    6538 = 427

    Convert 2378 to itsdecimal equivalent:

    2 x 82 = 128

    3 x 81 = 24

    7 x 80 = 7

    2378 = 159

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    44/61

    Two step Octal to Binary

    Binary to Hexadecimal

    Octal to Hexadecimal Conversion

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    45/61

    Decimal fraction to Binary fraction

    Convert decimal number 0.87510into binary.

    2 x0.875

    = 1.750 1

    2 x0.750

    = 1.5 1

    2 x 0.5 = 1.0 1

    The Binary number is 0.1112

    Convert decimal number0.12510 into binary.

    2 x0.125

    = 0.250 0

    2 x0.250

    = 0.5 0

    2 x 0.5 = 1.0 1

    The Binary number is 0.0012

    repeatedly doubling the decimal fraction.Until a 0 remains to the left of the decimalpoint or until the desired precision

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    46/61

    Convert decimal number 0.34510into binary.

    2 x 0.345 = 0.69 0

    2 x 0.69 = 1.38 1

    2 x 0.38 = 0.76 0

    2 x 0.76 = 1.52 1

    2 x 0.52 = 1.04 1

    2 x 0.04 = 0.08 0

    2 x 0.08 = 0.16 0

    2 x 0.16 = 0.32 0

    2 x 0.32 = 0.64 0

    2 x 0.64 = 1.28 1

    The Binary number is 0.0101102

    Decimal fraction to Binary fraction

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    47/61

    Binary fraction to Decimal fraction

    Convert binary number 0.0012 into decimal.. 0 0 1

    0 x 2-1 = 0 0 x 2-2 = 0 1 x 2-3 = 0.125

    0.0012

    = 0.12510

    Convert binary number 0.1112 into decimal.

    . 1 1 1

    1 x 2-1 = 0.5 1 x 2-2 = 0.25 1 x 2-3 = 0.125

    0.1112 = 0.5 + 0.25 + 0.125 =

    0.87510

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st term sy 2011-2012

  • 8/4/2019 Number System Mep

    48/61

    Binary fraction to Decimal fraction

    Convert binary number 0.01011000012 into decimal.. 0 1 0 1 1 0 0 0 0 1

    0 x2-1

    =0

    1 x 2-2

    =0.25

    0 x2-3

    =0

    1 x 2-4

    =0.0625

    1 x 2-5

    =0.03125

    0 x2-6

    =0

    0 x2-7

    =0

    0 x2-8

    =0

    0 x2-9

    =0

    1 x 2-10

    =0.0009765625

    0.01011000012 = 0.34472710

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st

    term sy 2011-2012

  • 8/4/2019 Number System Mep

    49/61

    Binary fraction to Decimal fractionConvert binary number 0.01011000012 into decimal.

    . 0 1 0 1 1 0 0 0 0 1

    0 x2-1

    =0

    1 x 2-2

    =0.25

    0 x2-3

    =0

    1 x 2-4

    =0.0625

    1 x 2-5

    =0.03125

    0 x2-6

    =0

    0 x2-7

    =0

    0 x2-8

    =0

    0 x2-9

    =0

    1 x 2-10

    =0.0009765625

    0.01011000012 = 0.34472710

    Convert decimal number 0.34510 into binary.

    2 x 0.345 = 0.69 0

    2 x 0.69 = 1.38 1

    2 x 0.38 = 0.76 0

    2 x 0.76 = 1.52 1

    2 x 0.52 = 1.04 1

    2 x 0.04 = 0.08 0

    2 x 0.08 = 0.16 0

    2 x 0.16 = 0.32 0

    2 x 0.32 = 0.64 0

    2 x 0.64 = 1.28 1

    The Binary number is 0.0101102 CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st

    term sy 2011-2012

  • 8/4/2019 Number System Mep

    50/61

    BINARY ARITHMETIC

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st

    term sy 2011-2012

  • 8/4/2019 Number System Mep

    51/61

    Binary Addition

    similar to the addition of decimal numbers.Numbers in each column are added togetherwith a possible carry from a previous column.

    carry bit

    00

    0

    + 10

    1

    + 01

    1

    + 11

    0

    +

    1

    1

    11

    1

    +

    1

    1

    +

    1

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1st

    term sy 2011-2012

  • 8/4/2019 Number System Mep

    52/61

    Binary Addition

    115

    61

    1011101

    1 0

    11

    000

    1

    + +

    150

    53

    1111100

    1 1100

    + +2 01

    0

    11

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1

    st

    term sy 2011-2012

  • 8/4/2019 Number System Mep

    53/61

    Binary Addition

    11 1010 1

    0101

    257

    09.

    + +3.5. 5

    0

    .1 1.

    00 .

    01 10

    10 01000

    5

    2520.

    ++

    9.

    11. 57

    .

    1 1.11 .

    1

    11

    11

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1

    st

    term sy 2011-2012

  • 8/4/2019 Number System Mep

    54/61

    Binary Subtraction

    With aborrow

    of 1

    00

    0

    - 10

    1

    - 01

    0

    -11

    1

    -

    e.g.

    163

    31

    1 00011 0 1

    1

    11

    011

    - - 0

    1

    6.25.5

    .751

    1 0.00 1

    1

    1

    1

    1

    1

    - - 1

    0

    4 .

    .CS 211 COMPUTER FUN DAMENTALS

    MEP_MIT-AQUINAS 1st

    term sy 2011-2012

  • 8/4/2019 Number System Mep

    55/61

    1s complement

    Switch all 0s to 1s and 1s to 0s

    Binary # 10110011

    1s complement 01001100

    2s complement

    Step 1: Find 1s complement of the number

    Binary # 11000110

    1s complement 00111001 Step 2: Add 1 to the 1s complement

    00111001

    00000001

    00111010

    Binary Subtraction using complement

    Binary subtraction is tricky due to the borrowing process and prone

    to error and alternative and easy way is using number complement

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1

    st

    term sy 2011-2012

  • 8/4/2019 Number System Mep

    56/61

    Binary Subtraction using 1s complement

    16

    331

    1 000

    111

    11

    011- -

    01

    1 000

    000011

    +

    0

    1 110

    1

    1

    1011 When subtraction is performed in the

    1s complement system, anyend-around carry is added to the leastsignificant bit

    Involves forming the 1s complement of the subtrahend andthen adding this complement to the minuend

    1s complement

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1

    st

    term sy 2011-2012

  • 8/4/2019 Number System Mep

    57/61

    Binary Subtraction using 2s complement

    16

    331

    1 000

    111

    11

    011- -

    01

    1 000

    011011

    +

    0

    1 110

    1

    1

    When subtraction is performed in the2s complement system, anyend-around carry is dropped

    Involves forming the 2s complement of the subtrahend andthen adding this complement to the minuend

    2s complement

    001 11 +

    10110

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1

    st

    term sy 2011-2012

  • 8/4/2019 Number System Mep

    58/61

    011 0.0

    0 1

    1

    1

    1

    1

    1

    - 1

    0

    .

    .

    111 0 .0

    1 0

    01

    0

    1

    + 1.

    .

    1

    00

    11

    1 1111.00

    111 0.0

    1 1

    11

    0

    1

    + 1.

    .

    0

    00

    1

    1

    using 2s complementusing 1s complement

    Binary Subtraction

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1

    st

    term sy 2011-2012

  • 8/4/2019 Number System Mep

    59/61

    Binary Multiplication and division

    00

    0

    x10

    0

    x0

    1

    1

    x1

    1

    0

    x

    multiplication rule

    0 1 0

    Division rule

    =1 1 1 =

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1

    st

    term sy 2011-2012

  • 8/4/2019 Number System Mep

    60/61

    Binary Multiplication

    10

    120

    x 12 1 000

    111

    + 11 10

    0 0001 001

    0 0001 0011 000

    2.5

    625

    x1.25

    250

    1 011

    11

    + .1 .0

    1010 00

    1 10

    . 010

    3.125

    1

    CS 211 COMPUTER FUN DAMENTALSMEP_MIT-AQUINAS 1

    st

    term sy 2011-2012

  • 8/4/2019 Number System Mep

    61/61

    25

    5

    5

    11 0 11 00101 1

    01 1

    01 101 1

    11 1 10 00101 0

    01101 111

    1

    292.416

    12

    0.

    0

    0

    0000

    01 011

    0000

    01 0 00

    110. 10101..

    Binary Division

    CS 211 COMPUTER FUN DAMENTALSst