Top Banner

of 25

Goal_1 Numbering System and Digital Codes

Jun 02, 2018

Download

Documents

jaltiti
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 8/10/2019 Goal_1 Numbering System and Digital Codes

    1/25

    ELEC 224 J. Altiti1

    Goal 1

    Digital & Analog Quantities

    Number Systems

  • 8/10/2019 Goal_1 Numbering System and Digital Codes

    2/25

    ELEC 224 J. Altiti2

    Digital & Analog Quantities

    Analog quantity have continuous values. The figure below shows a graph of air temperature vs time

    of day.

    The air temperature changes over a continues range of values. During the day the temperature

    does not go from say 70oto 75oinstantaneously. It takes on all the infinite values in between.

    another examples of analog quantity is the sine wave shown below. Other examples are distance,

    sound, time and pressure

    Example of an analog electronic system is shown below

  • 8/10/2019 Goal_1 Numbering System and Digital Codes

    3/25

    ELEC 224 J. Altiti3

    Digital quantity have discrete values. Varies in discrete (separate) stepsDigital technology is widely used. Examples:

    o Computerso Manufacturing systemso Medical Scienceo Transportationo Entertainmento Telecommunications

    The figure below shows a graph of a digital signal .

    The digital sequence of the above signal is 1010101010 in reality 5v 0v 5v 0v 5v 0v 5v 0v 5v 0v

    another example of a digital signal is shown below. Note that each level represent

    The digital sequence of the above signal is 11010100 in reality 5v 5v 0v 5v 0v 5v 0v 0v

    Example of a system that uses digital and analog electronics is shown below

  • 8/10/2019 Goal_1 Numbering System and Digital Codes

    4/25

    ELEC 224 J. Altiti4

    Advantages and disadvantages of both systems

    Number SystemsUnderstanding digital systems requires an understanding of the decimal,binary, octal, and

    hexadecimalnumbering systems. The most familiar is the decimal number system (conventional

    number system) that uses ten digits: 0,1,2,3,4,5,6,7,8, and 9.

    Decimal Number System:Base: 10

    Decimal Digits: 0 1 2 3 4 5 6 7 8 9

    Weights: ----- 10000 1000 100 10 1 . 0.1 0.01 0.001 0.0001 ------

    ----- 104 103 102 101 100 . 10-1 10-2 10-3 10-4.

    Example: The number 2745.21410.

    The digit 2is the Most Significant Digit (MSD)

    The digit 4is the Least Significant Digit (LSD)

    The decimal number 2745.214 consist of sevendecimal digits

    The formula below is used to calculate the largest decimal number that can be represented with n

    digits

    NumberDecimalLargest1Basen

    n: Number of digits

    Base: Number system base (10)

    With 5 decimal digits (n = 5) the largest decimal number is

    999991105

    Analog Digital Susceptible to noise Very Immune to noise

    Less efficient in transmission More efficient in transmission

    Less bandwidth Greater bandwidth

  • 8/10/2019 Goal_1 Numbering System and Digital Codes

    5/25

    ELEC 224 J. Altiti5

    Example: 598.74210= 0598.742010= 00598.7420010= 000598.74200010

    100 10 1 . 0.1 0.01 0.001 0.0001

    102

    101

    100

    . 10-1

    10-2

    10-3

    10-4

    5 9 8 . 7 4 2 0

    (5x102) + (9x101) + (8x100) + (7x10-1) + (4x10-2) + (2x10-3) + (0x 10-4)

    (5x100) + (9x10) + (8x1) + (7x0.1) + (4x 0.01) + (2x0.001) + (0 x 0.0001)

    500 + 90 + 8 + 0.7 + 0.04 + 0.002 + 0

    = 598.74210

    Binary Number System:

    Base: 2

    Binary Digits (Bit): 0 1

    Weights: ----- 16 8 4 2 1 . 0.5 0.25 0.125 0.0625 ------

    ----- 24 23 22 21 20 . 2-1 2-2 2-3 2-4.

    Example: 1010102

    The 1is the Most Significant Bit (MSB)

    The 0 is the Least Significant Bit (LSB)

    The binary number 101010 consist of 6 Bits (Binary Digits)

    What is the decimal number that is equal to the binary number 101010 ?

    32 16 8 4 2 1

    25 24 23 22 21 20

    1 0 1 0 1 0

    (1x25) + (0x24) + (1x23) + (0x22) + (1x21) + (0x20)

    (1x32) + (0x16) + (1x8) + (0x4) + (1x2) + (0x1)

    32 + 0 + 8 + 0 + 2 + 0

    = 4210. The binary number 1010102= 4210in decimal

    The formula below is used to calculate the largest decimal number that can

    be represented in binary with n bits

    NumberDecimalLargest1Basen

    n: number of bits

    Base: number system base (2)

    With 2 bits (binary digits) the largest decimal number that can be represented in

    binary is

    3122

    10

    That is with 2 bits, a range of decimal numbers from 0 to 3 can be represented. That

    is a total of 4 binary combinations where each binary combination represent a

    decimal number.

  • 8/10/2019 Goal_1 Numbering System and Digital Codes

    6/25

    ELEC 224 J. Altiti6

    The formula below is used to calculate the range of decimal numbers (binary

    combination) that can be represented in binary with n bits.n

    Base n: number of bits

    Base: number system base (2)

    Example: How many decimal numbers can we represent in binary with 2 bits

    422

    2 1

    b1 b0 Decimal

    0 0 0

    0 1 1

    1 0 2

    1 1 3

    Example: How many bits are required to represent the decimal number 3710

    With 5 bits (binary digits) the largest decimal number is

    10

    5 3112

    and 32 (25) decimal numbers (from 0 to 31) can be represented

    With 6 bits (binary digits) the largest decimal number is

    10

    6 6312

    and 64 (26

    ) decimal numbers (from 0 to 63) can be represented

    From the above it is obvious that 6 bits are needed to represent the decimal

    number 37

    Weights ----- 32 16 8 4 2 1

    ----- b5 b4 b3 b2 b1 b0

    1 0 0 1 0 1

    Example: The table below is for 4 bits (n =4).

    b3 b2 b1 b0

  • 8/10/2019 Goal_1 Numbering System and Digital Codes

    7/25

    ELEC 224 J. Altiti7

    Example: 1011.1012= 01011.1012= 001011.101002= 0001011.1010002

    8 4 2 1 . 0.5 0.25 0.125

    23 22 21 20 . 2-1 2-2 2-3

    1 0 1 1 . 1 0 1

    (1x23) + (0x22) + (1x21) + (1x20) + (1x2-1) + (0x 2-2) + (1x 2-3)

    (1x8) + (0x4) + (1x2) + (1x1) + (1x0.5) + (0x0.25) + (1x0.125)

    8 + 0 + 2 + 1 + 0.5 + 0 + 0.125

    = 11.62510. The binary number 1011.1012= 11.62510in decimal

    and the decimal number 11.62510= 1011.1012in binary

    Octal Number System:Base: 8

    Octal Digits: 0 1 2 3 4 5 6 7

    Weights: ----- 4096 512 64 8 1 . 0.125 0.015625 ------

    ----- 84 83 82 81 80 . 8-1 8-2

    Octal numbers were used in old computer systems. Now it is rarely used.

    Example: 50738

    The 5is the Most Significant Digit (MSD)

    The 3 is the Least Significant Digit (LSD)

    The octal number 5073 consist of 4 octal digits

    What is the decimal number that is equal to the octal number 5073 ?

    512 64 8 1

    83 8

    2 8

    1 8

    0

    5 0 7 3

    (5x83) + (0x82) + (7x81) + (3x80)

    (5x512) + (0x64) + (7x8) + (3x1)

    2560 + 0 + 56 + 3

    = 261910. The octal number 50738= 261910in decimal

  • 8/10/2019 Goal_1 Numbering System and Digital Codes

    8/25

    ELEC 224 J. Altiti8

    Hexadecimal Number System:Base: 16

    Hexadecimal Digits: 0 1 2 3 4 5 6 7 8 9 A B C D E F(10) (11) (12) (13) (14) (15)

    Weights: ----- 4096 256 16 1 . 0.0625 0.00390625 ------

    ----- 163 162 161 160 . 16-1 16-2 -------.

    Example: 3A91C16 or 3A91Ch

    The 3is the Most Significant Digit (MSB)

    The C is the Least Significant Digit (LSB)

    The Hex number 3A91C consist of 5 hexadecimal digits

    What is the decimal number that is equal to the hex number 5C3A ?

    4096 256 16 1163 162 161 160

    5 C 3 A

    (5x163) + (Cx162) + (3x161) + (Ax160)

    (5x4096) + (12x256) + (3x16) + (10x1)

    20480 + 03072 + 48 + 10

    = 2361010. The Hexadecimal number 5C3A16= 2361010in decimal

    Binary Coded Decimal (BCD) Number SystemBinary Coded Decimal (BCD) is another way to present decimal numbers in binary form. BCD iswidely used and combines features of both decimal and binary systems. Each decimal digit is

    converted to a 4 bit binary equivalent.

    Decimal Digit BCD Equivalent

    0 00001 00012 00103 00114 0100

    5 01016 01107 01118 10009 1001

    Example: What is the decimal number that is equal to the 100001110100BCD

    1000 0111 0100

    8 7 4

    So the BCD 100001110100 is equal to the decimal number 874

    Example: What is the BCD equivalent to the decimal number 1095 ?1 0 9 5

    0001 0000 1001 0101

    So the decimal number 1095 has a BCD equivalent of 0001000010010101

  • 8/10/2019 Goal_1 Numbering System and Digital Codes

    9/25

    ELEC 224 J. Altiti9

    Gray Codehas the property that only one bit changes from one number to the next in the sequence. The gray

    code is used in applications where numbers change rapidly.

    The table shows the representations of decimal numbers in Binary, Octal, Hexadecimal, BCD

    and Gray code.

    Decimal Binary Gray

    0 0000 0000

    1 0001 0001

    2 0010 0011

    3 0011 0010

    4 0100 0110

    5 0101 0111

    6 0110 0101

    7 0111 0100

    8 1000 1100

    9 1001 1101

    10 1010 1111

    11 1011 1110

    12 1100 1010

    13 1101 1011

    14 1110 1001

    15 1111 1000

    Decimal Binary Octal Hexadecimal BCD Gray

    0 0000 0 0 0000 000

    1 0001 1 1 0001 0001

    2 0010 2 2 0010 0011

    3 0011 3 3 0011 0010

    4 0100 4 4 0100 0110

    5 0101 5 5 0101 01116 0110 6 6 0110 0101

    7 0111 7 7 0111 0100

    8 1000 10 8 1000 1100

    9 1001 11 9 1001 1101

    10 1010 12 A 0001 0000 1111

    11 1011 13 B 0001 0001 1110

    12 1100 14 C 0001 0010 1010

    13 1101 15 D 0001 0011 1011

    14 1110 16 E 0001 0100 1001

    15 1111 17 F 0001 0101 1000

  • 8/10/2019 Goal_1 Numbering System and Digital Codes

    10/25

    ELEC 224 J. Altiti10

    ASCII CodeASCIIAmerican Standard Code for Information Interchange. Each code represents a character

    or function found on a computer keyboard. ASCII code is used to transfer information between

    computers

    and printers, and for internal storage.

    The ASCII code is a seven bit code. With 7 bits there are 128 possible combinations.

    27= 128 possible codes (from 0 to 127)

    The Extended ASCII code (80h to FFh or 12810to 25510) represent non-English alphabetic

    characters such as:

    - Currency symbols

    - Greek letters

    - Math symbols

    - Drawing characters

    - Bar graphing characters

    - Shading characters

    The following web site has the complete ASCII tablehttp://www.lookuptables.com/

    http://www.lookuptables.com/http://www.lookuptables.com/http://www.lookuptables.com/http://www.lookuptables.com/
  • 8/10/2019 Goal_1 Numbering System and Digital Codes

    11/25

    ELEC 224 J. Altiti11

    Conversion between Number Systems

    The Figure below demonstrate the various possible conversion between number systems

    g 3 bits : Group every 3 bits g 4 bits : Group every 4 bits

    f 3 bits : Form 3 bits for every octal digit f 4 bits : Form 4 bits for each hexadecimal digit

    The following terms are used in digital systems Bit, Nibble, Byte, KiloByte, MegaByte and GigaByte

    -Bit: a single binary digit.

    Example: 1 or 0

    - Nibble: a group of 4 binary digits (4 bits). 1510is the maximum decimal number that can be

    represented with one nibble.

    Example: 1101

    - Byte: a group of 8 binary digits (8 bits). 25510is the maximum decimal number that can be

    represented with one byte.Example: 10110101

    - Word: a group of 16 binary digits (16 bits). 65535 is the maximum decimal number that can be

    represented with one word.

    Example: 1011101101110011 = ------------------10

    - KiloBit: is 1024 binary digits (1024 bits).

    - KiloByte: is 1024 Byte = 1024 x 8 bits = 8192 bits.

    - MegaByte: 1024 kiloByte = 1024 x 8192 bits = 8,388,608 bits.

    - GigaByte: 1024 MegaByte = 1024 x 8,388,608 bits = 8,589,934,592 bits .

  • 8/10/2019 Goal_1 Numbering System and Digital Codes

    12/25

    ELEC 224 J. Altiti12

    Decimal to Binary Conversion

    The integer portion of the decimal number will be divided by 2 repeatedly till the quotient is equal 0. Thefraction part will be multiplied by 2 till the fraction is equal 0.

    Example: Convert the decimal number 25.8125 to binary.

    Divison Quotient Reminder Bit

    25/2 = 12 1 (LSB)

    12/2 = 6 0 0

    6/2 = 3 0 0

    3/2 = 1 1

    1/2 = 0 1 (MSB)

    Multiply Integer Fraction Bit

    0.8125 x 2 = 1 0.625 1 (MSB)

    0.625 x 2 = 1 0.250 1

    0.250 x 2 = 0 0.5 0

    0.5 x 2 = 1 0 1 (LSB)

    Finally 25.812510= 11001.11012

  • 8/10/2019 Goal_1 Numbering System and Digital Codes

    13/25

    ELEC 224 J. Altiti13

    Decimal to Octal Conversion

    The integer portion of the decimal number will be divided by 8 repeatedly till the quotient is equal 0. Thefraction part will be multiplied by 8 till the fraction is equal 0.

    Example: Convert the decimal number 25.8125 to octal.

    Divison Quotient Reminder Digit

    25/8 = 3 1/ 8 1 (LSD)

    3/8 = 0 3/ 8 3 (MSD)

    Multiply Integer Fraction Bit

    0.8125 x 8 = 6 0.5 6 (MSD)

    0.5 x 8 = 4 0 4 (LSD)

    Finally 25.812510= 31.648

    Decimal to Hexadecimal Conversion

    The integer portion of the decimal number will be divided by 16 repeatedly till the quotient is equal 0. The

    fraction part will be multiplied by 16 till the fraction is equal 0.

    Example: Convert the decimal number 25.8125 to octal.

    Divison Quotient Reminder Digit

    25/16 = 1 9/ 16 9 (LSD)1/16 = 0 1/ 16 1 (MSD)

    Multiply Integer Fraction Digit

    0.8125 x 16 = 13 0 D (MSD)

    Finally 25.812510= 19.D16

    Binary to Hexasecimal Conversion

    1. Starting from the Right of the binary number group every 4-bits2. Replace each group with the hexadecimal digit equivalent

    Example: Find the hexadecimal and decimal equivalent of the following binary number 100111110010 ?

    Hexadecimal

    1. 1001 1111 0010

    2. 9 F 2

    Decimal

    2048 1024 512 256 128 64 32 16 8 4 2 1

    211 210 29 28 27 26 25 24 23 22 21 20

    1 0 0 1 1 1 1 1 0 0 1 0= 2048 + 256 + 128 + 64 + 32 + 16 + 2 = 2,54610

    Finally 1001111100102= 9F216= 2,54610

  • 8/10/2019 Goal_1 Numbering System and Digital Codes

    14/25

    ELEC 224 J. Altiti14

    Binary to Octal Conversion1. Starting from the Right of the binary number group every 3-bits

    2. Replace each group with the octal digit equivalent

    Example: Find the octal equivalent of the following binary number 100111110010 ?

    Hexadecimal

    1. 100 111 110 010

    2. 4 7 6 2

    Finally 1001111100102= 47628= 2,54610

    Hexadecimal to Binary ConversionReplace each hexadecimal digit with its 4-bit binary equivalent (form 4-bits for each hexadecimal digit)

    Example: Find the binary equivalent of the following hexadecimal number F7C9?

    F 7 C 9

    1111 0111 1100 1001

    Finally F7C916= 11110111110010012= 63,43310

    Octal to Binary Conversion

    Replace each octal digit with its 3-bit binary equivalent (form 3-bits for each octal digit)

    Example: Find the binary equivalent of the following octal number 3741?

    3 7 4 1

    011 111 100 001

    Finally 37418= 0111111000012= 2,01710

    Hexadecimal to Octal Conversion

    1. Convert each hexadecimal digit to its 4-bit binary equivalent.2. follow the procedure for converting binary to octal.

    Example: Find the octal equivalent of the following hexadecimal number D94A?

    1. D 9 4 A

    1101 1001 0100 1010

    D94Ah = 11011001010010102

    2. 001 101 100 101 001 010

    1 3 4 5 1 2

    Finally D94A16= 11011001010010102= 1345128

  • 8/10/2019 Goal_1 Numbering System and Digital Codes

    15/25

    ELEC 224 J. Altiti15

    Octal to Hexadecimal Conversion1. Convert each octal digit to its 3-bit binary equivalent.

    2. follow the procedure for converting binary to hexadecimal.

    Example: Find the hex equivalent of the following octal number 647?

    1. 6 4 7

    110 100 111

    6478= 1101001112

    2. 0001 1010 0111

    1 A 7

    Finally 6478= 1101001112= 1A716

    Binary to Gray Code Conversion1. The MSB in Gray code is the same as the corresponding MSB in the binary number.

    2. Going from left to right, add each adjacent pair of binary code bits to get the next gray code bit.

    Discard Carries

    Binary addition

    1

    0+

    0

    0

    0+

    1

    1

    1+

    0

    1+

    0

    1

    1

    1

    Example: Convert 101102to Gary code.

    1 + 0 + 1 + 1 + 0 Binary

    1 1 1 0 1 Gray

    Finally 101102= Gray code 11101

    Gray to Binary Code Conversion1. The MSB in the binary number is the same as the corresponding bit in the Gray code.

    2. Add each binary bit generated to the Gray code bit in the next adjacent position. Discard carries.

    Example: Convert the Gary code 11011 to binary .

    1 0+

    1 1

    0 1

    0 1

    ++0

    1

    +

    Gray

    Binary

    Finally Gray code 11011 = 100102= 1810

  • 8/10/2019 Goal_1 Numbering System and Digital Codes

    16/25

    ELEC 224 J. Altiti16

    Signed Numbers

    Since it is only possible to show magnitude with a binary number, the sign (+ or -) is shown by adding an

    extra sign bit.

    A sign bit of 0 indicates a positive number.

    A sign bit of 1 indicates a negative number.

    There are 2 methodes to represent signed numbers

    Sign-magnitude System

    2s complement system

    Sign-magnitude SystemThe last bit is the sign bit and does has no weight. It is used indicate the sign (+ or -). The remaining bits

    corresponds to the number value.

    Example:

    Although the sign-magnitude system is straight forwad, computers and calculators do not normally use it,

    because the circuit implementation is complex.

    2s complement System

    The 2s complement system is the most commonly used way to represent signed numbers.

    To change the sign of a binary number perform the 2s complementas follows

    Invert each bit. 1 to 0 and 0 to 1. This process is called the 1s complement

    Add 1 to the 1s complement.

    A short cut to performing 2s complement Starting from the right of the binary number, leave all the bits unchanged till the first 1 is

    encountered

    Invert all the bits after the first encountered 1

    A number is negated when converted to the opposite sign. A binary number can be negated by taking the 2s

    complement of it.

    .

  • 8/10/2019 Goal_1 Numbering System and Digital Codes

    17/25

    ELEC 224 J. Altiti17

    Example: Find the negative of the decimal number 45 in binary using 7-bits.

    4510= 0 1 0 1 1 0 12

    Perform 1s complement1 0 1 0 0 1 02

    Add 1 to 1s complement

    1 0 1 0 0 1 0

    +

    1

    1 0 1 0 0 1 1 = -4510

    Finally + 4510= 0 1 0 1 1 0 12 and - 4510 = 1 0 1 0 0 11

    Range of Values with 2s complement System

    The formula below is used to calculate the minimum (negative) and the maximum (positoive)

    numbers can be calculated as follows

    minimum (negative) number =(2n1)

    maximum (positive) number = + (2

    n1

    1)n: number of bits

    Example: what are the range of signed and unsigned decimal numbers that can be represented with

    4-bits ?

    Signed

    Minimum (negative) decimal number =(241) =(23) =8

    Maximum (positive) decimal number = + (2n11) = (231) = 7

    Unsigned

    Maximum unsignd decimal number = 241 = 15

    Finally

    All signed decimal number from8 to 7 can be represented with 4-bits.

    All unsigned decimal numbers from 0 to 15 can be represented with 4-bits.

  • 8/10/2019 Goal_1 Numbering System and Digital Codes

    18/25

    ELEC 224 J. Altiti18

    The figure below demonstrate the signed and unsigned decimal numbers represented with

    4-bits

  • 8/10/2019 Goal_1 Numbering System and Digital Codes

    19/25

    ELEC 224 J. Altiti19

    Arithmetic Operations with Signed numbers

    The basic arithmetic operations are Addition and Subtraction In this sections only Binary, Hexadecimal and

    BCD arithmetic operations will be discussed.

    Binary Addition

    The parts of any addition function are:

    1. Augend2. Addend3. Sum

    Four conditions for adding numbers:

    1. Both numbers are positive.2. A positive number that is larger than a negative number.3. A negative number that is larger than a positive number.4. Both numbers are negative.

    Signs for Addition

    1. When both numbers are positive, the sum is positive.2. When the larger number is positive and the smaller is negative, the sum is positive. The carry is

    discarded.

  • 8/10/2019 Goal_1 Numbering System and Digital Codes

    20/25

    ELEC 224 J. Altiti20

    3. When the larger number is negative and the smaller is positive, the sum is negative (2scomplement form).

    4. When both numbers are negative, the sum is negative (2s complement form). The carry bit isdiscarded.

    Example: Add 910to 410in binary .

    910= 0010112

    410= 0001002

    Finally 910 + 410= 1310= 011012

    Example: Add 910to -410in binary.

    910= 010012

    -410= 111002

    Finally 910 + (-410) = 510= 01012

  • 8/10/2019 Goal_1 Numbering System and Digital Codes

    21/25

    ELEC 224 J. Altiti21

    Example: Add -910to 410in binary.

    -910= 101112

    410= 001002

    Finally -910 + 410= -510= 110112

    Example: Add -910 and -410in binary.

    -910= 101112

    -410= 111002

    Finally -910 + (-410) = -1310= 100112

    Example: Add -910 and 910in binary.

    -910= 101112

    910= 010012

    Hexadecimal Addition

    1. Add the hex digits in decimal.2. If the sum is 15 or less express it directly in hex digits.

    3. If the sum is greater than 15, subtract 16 and carry 1 to the next position.4. When the MSD in a hex number is 8 or greater, the number is negative. When the MSD is 7 or

    less, the number is positive.

  • 8/10/2019 Goal_1 Numbering System and Digital Codes

    22/25

    ELEC 224 J. Altiti22

    Example: Add 2510to 3010in hexadecimal.

    2510= 1916

    3010= 1E16

    Finally 2510+ 3010= 5510= 3716Example: Add A73486516to 1259D616.

    Example: Add 34A87BC16to 12DF45816.

    BCD Addition

    1. Convert each BCD number to its 4-bit binary equivalent.2. Add the two BCD numbers using the binary addition.3. If the sum of two BCD numbers is less than or equal to 9, the sum is a valid BCD number.4. If the sum of two BCD numbers is greayer than 9, a binary 6 is added. This will always cause a

    carry.

    Example: Add the 8 to 5 using BCD.

    8 1000

    +5 +0101

    13 1101 is 13 ( > 9)

    Note that the result is MORE THAN 9, so add 6.

  • 8/10/2019 Goal_1 Numbering System and Digital Codes

    23/25

    ELEC 224 J. Altiti23

    8 1 0 0 0

    +5 + 0 1 0 1

    13 1 1 0 1 is 13 (> 9)

    1 1 1 0 1 13

    + 0 1 1 0 add 6

    1 0 0 1 1 0001= 1 and 0011 = 3

    0001| 0011 Final answer (two digits) = 13

    Finally adding 8BCDto 5BCD= 13BCD

    Example: Add 1897BCDto 2905BCD

    Finally adding 1897BCDto 2905BCD= 4802BCD

  • 8/10/2019 Goal_1 Numbering System and Digital Codes

    24/25

    ELEC 224 J. Altiti24

    Binary Subtraction

    The parts of any subtraction function are:

    1. Minuend2. Subtrahend3. Difference

    Subtraction is addition with the sign of the subtrahend changed.

    1. The number subtracted (subtrahend) is negatedby taking the 2s complement.2. The result is added to the minuend.3. The answer represents the difference.4. Discard any final carry bit.

    Example: Compute 1310- 510in binary.

    1310510 = 1310+ (-510)

    1310 = 011012

    510 = 001012 -510= 110112

    Finally 1310+ (-510) = 810= 011012+ 110112= 010002

    Example: Compute 5101210.

    5101210 = 510+ (-1210)

    510 = 001012

    1210 = 011002 -1210= 101002

    Finally 510+ (-1210) = -710= 001012+ 101002= 110012

  • 8/10/2019 Goal_1 Numbering System and Digital Codes

    25/25

    Hexadecimal Subtraction

    1. Subtract the hex digits in decimal.

    2. If the sum is 15 or less express it directly in hex digits.3. If the difference is negative, borrow 1 from next hex digit and add 16 to the differenc.

    Example: Compute 84162A16

    Finally 84162A16= 5A16

    Example: Compute 4787C141612DF45816

    Finally 4787C141612DF45816= 34A87BC16