Top Banner

of 37

Number Systems Lecture 2

Feb 04, 2018

Download

Documents

Amir Sollehin
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
  • 7/21/2019 Number Systems Lecture 2

    1/37

    MCT 2333MCT 2333

    Digital Number System

    Dr. Hazlina Md Yusof

  • 7/21/2019 Number Systems Lecture 2

    2/37

    Digital Number SystemDigital Number System

    The hexadeimal number system isintrodued in this ha!ter.

    Sine di"erent number systems may

    be used in a system# it is im!ortant fora tehniian to understand ho$ toon%ert bet$een them.

    &inary odes that are used to

    re!resent di"erent information arealso desribed in this ha!ter.

  • 7/21/2019 Number Systems Lecture 2

    3/37

    &inary to Deimal&inary to Deimal

    Con%ersionCon%ersionCon%ert binary to deimal by

    summing the !ositions thatontain a '.

    10012345 371432222222 =++=+++++

    1 0 0 1 0 21

  • 7/21/2019 Number Systems Lecture 2

    4/37

    Deimal to &inaryDeimal to &inary

    Con%ersionCon%ersion T$o methods to on%ert deimal

    to binary( )e%erse !roess desribed in 2*'

    +se re!eated di%ision

  • 7/21/2019 Number Systems Lecture 2

    5/37

    Deimal to &inaryDeimal to &inary

    Con%ersionCon%ersion )e%erse !roess desribed in 2*

    ' Note that all !ositions must be

    aounted for025

    1020200237 +++++=

    1 0 0 1 0 21

  • 7/21/2019 Number Systems Lecture 2

    6/37

    Deimal to &inaryDeimal to &inary

    Con%ersionCon%ersion)e!eated di%ision ste!s(

    Di%ide the deimal number by 2

    ,rite the remainder after eah

    di%ision until a -uotient of zero isobtained.

    The rst remainder is the /S& andthe last is the MS& Note# $hen done on a alulator# a

    frational ans$er indiates a remainderof '.

  • 7/21/2019 Number Systems Lecture 2

    7/37

    Deimal to &inary Con%ersionDeimal to &inary Con%ersion

    )e!eated di%ision0 This 1o$hart

    desribes the!roess and anbe used to on%ertfrom deimal to

    any other numbersystem.

  • 7/21/2019 Number Systems Lecture 2

    8/37

    Hexadeimal NumberHexadeimal Number

    SystemSystemMost digital systems deal $ith grou!sof bits in e%en !o$ers of 2 suh as #'# 32# and 4 bits.

    Hexadeimal uses grou!s of 4 bits.&ase '

    ' !ossible symbols

    5*6 and 7*8

    7llo$s for on%enient handling of longbinary strings.

  • 7/21/2019 Number Systems Lecture 2

    9/37

    Hexadeimal NumberHexadeimal Number

    SystemSystemCon%ert from hex to deimal by

    multi!lying eah hex digit by its

    !ositional $eight. 9xam!le(

    )16(3)16(6)16(1163 01216

    ++=

    131662561 ++=

    10355=

  • 7/21/2019 Number Systems Lecture 2

    10/37

    Hexadeimal NumberHexadeimal Number

    SystemSystem

    Con%ert from deimal to hex by using there!eated di%ision method used for deimal

    to binary and deimal to otal on%ersion.Di%ide the deimal number by 'The rst remainder is the /S& and the last

    is the MS&.

    Note# $hen done on a alulator a deimalremainder an be multi!lied by ' to get theresult. :f the remainder is greater than 6# theletters 7 through 8 are used.

  • 7/21/2019 Number Systems Lecture 2

    11/37

    Hexadeimal NumberHexadeimal Number

    SystemSystem

    9xam!le of hex to binaryon%ersion(

    682'3 ; 6 8 2

    '55' '''' 55'5 ;'55'''''55'52

    Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

    Hexadecimal 0 1 2 3 4 5 6 7 8 9 A B C D E F

    Binary 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111

  • 7/21/2019 Number Systems Lecture 2

    12/37

    Hexadeimal NumberHexadeimal Number

    SystemSystemCon%ert from binary to hex by

    grou!ing bits in four starting $iththe /S&.

    9ah grou! is then on%erted tothe hex e-ui%alent

    /eading zeros an be added to

    the left of the MS& to ll out thelast grou!.

  • 7/21/2019 Number Systems Lecture 2

    13/37

    2*3 Hexadeimal Number2*3 Hexadeimal Number

    SystemSystem

    9xam!le of binary to hex on%ersion.

    (Note the addition of leading zeroes)

    '''5'55''52 ; 00'' '5'5 5''5

    ; 3 7

    ; 37'3Counting in hex re-uires a reset and arry

    after reahing 8.

    Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

    Hexadecimal 0 1 2 3 4 5 6 7 8 9 A B C D E F

    Binary 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111

  • 7/21/2019 Number Systems Lecture 2

    14/37

    Hexadeimal NumberHexadeimal Number

    SystemSystemHexadeimal is useful for

    re!resenting long strings of bits.+nderstanding the on%ersion

    !roess and memorizing the 4 bit!atterns for eah hexadeimaldigit $ill !ro%e %aluable later.

  • 7/21/2019 Number Systems Lecture 2

    15/37

    &inary 7ddition&inary 7ddition

    &inary numbers are added li

  • 7/21/2019 Number Systems Lecture 2

    16/37

    )e!resenting Signed)e!resenting Signed

    NumbersNumbersSine it is only !ossible to sho$

    magnitude $ith a binary number# thesign => or ? is sho$n by adding anextra @signA bit.

    7 sign bit of 5 indiates a !ositi%enumber.

    7 sign bit of ' indiates a negati%e

    number.The 2Bs om!lement system is themost ommonly used $ay tore!resent signed numbers.

  • 7/21/2019 Number Systems Lecture 2

    17/37

    )e!resenting Signed)e!resenting Signed

    NumbersNumbers:n order to hange a binary number to 2Bs

    om!lement it must rst be hanged to 'Bsom!lement. To on%ert to 'Bs om!lement# sim!ly hange eah bit to its

    om!lement =o!!osite?. To on%ert 'Bs om!lement to 2Bs om!lement add ' to the

    'Bs om!lement.7 !ositi%e number is true binary $ith 5 in the sign

    bit.

    7 negati%e number is in 2Bs om!lement form $ith 'in the sign bit.

  • 7/21/2019 Number Systems Lecture 2

    18/37

    )e!resenting Signed)e!resenting Signed

    NumbersNumbers7 number is negated $hen on%ertedto the o!!osite sign.

    7 binary number an be negated by

    ta

  • 7/21/2019 Number Systems Lecture 2

    19/37

    7ddition in the 2Bs Com!lement7ddition in the 2Bs Com!lement

    SystemSystem

    erform normal binary addition ofmagnitudes.

    The sign bits are added $ith the magnitude

    bits.:f addition results in a arry of the sign bit# the

    arry bit is ignored.:f the result is !ositi%e it is in !ure binary

    form.:f the result is negati%e it is in 2Bs om!lement

    form.

  • 7/21/2019 Number Systems Lecture 2

    20/37

    Subtration in the 2Bs Com!lementSubtration in the 2Bs Com!lement

    SystemSystem

    The number subtrated =subtrahend?is negated.

    The result is added to the minuend.

    The ans$er re!resents the di"erene.:f the ans$er exeeds the number of

    magnitude bits an o%er1o$ results.

  • 7/21/2019 Number Systems Lecture 2

    21/37

    Multi!liation of &inaryMulti!liation of &inary

    NumbersNumbersThis is similar to multi!liation of

    deimal numbers.9ah bit in the multi!lier is multi!lied

    by the multi!liand.The results are shifted as $e mo%e

    from /S& to MS& in the multi!lier.7ll of the results are added to obtain

    the nal !rodut.

  • 7/21/2019 Number Systems Lecture 2

    22/37

    &inary Di%ision&inary Di%ision

    This is similar to deimal long di%ision.:t is sim!ler beause only ' or 5 are

    !ossible.

    The subtration !art of the o!eration isdone using 2Bs om!lement subtration.

    :f the signs of the di%idend and di%isorare the same the ans$er $ill be !ositi%e.

    :f the signs of the di%idend and di%isorare di"erent the ans$er $ill be negati%e.

  • 7/21/2019 Number Systems Lecture 2

    23/37

    Hexadeimal 7rithmetiHexadeimal 7rithmeti

    Hex addition( 7dd the hex digits in deimal.

    :f the sum is ' or less ex!ress it diretly inhex digits.

    :f the sum is greater than '# subtrat 'and arry ' to the next !osition.

    Hex subtration 0 use the samemethod as for binary numbers.

    ,hen the MSD in a hex number is orgreater# the number is negati%e.,hen the MSD is E or less# the numberis !ositi%e.

  • 7/21/2019 Number Systems Lecture 2

    24/37

    &CD&CD

    &inary Coded Deimal =&CD? isanother $ay to !resent deimal

    numbers in binary form.&CD is $idely used and ombines

    features of both deimal and binary

    systems.9ah digit is on%erted to a binary

    e-ui%alent.

  • 7/21/2019 Number Systems Lecture 2

    25/37

    &CD&CD

    To on%ert the number E4'5to &CD(

    E 4

    5'55 5''' 5'55 ; 5'555'''5'55&CD

    9ah deimal digit is re!resented using 4 bits.

    9ah 4*bit grou! an ne%er be greater than 6.

    )e%erse the !roess to on%ert &CD to deimal.

  • 7/21/2019 Number Systems Lecture 2

    26/37

    &CD&CD

    &CD is not a number system.&CD is a deimal number $ith

    eah digit enoded to its binary

    e-ui%alent.7 &CD number is not the same as

    a straight binary number.

    The !rimary ad%antage of &CD isthe relati%e ease of on%erting toand from deimal.

  • 7/21/2019 Number Systems Lecture 2

    27/37

    Fray CodeFray Code

    The gray ode is used ina!!liations $here numbershange ra!idly.

    :n the gray ode# only one bithanges from eah %alue to thenext.

  • 7/21/2019 Number Systems Lecture 2

    28/37

    Fray CodeFray Code

    &inary Fray Code

    555 55555' 55'5'5 5''

    5'' 5'5'55 ''5'5' '''''5 '5'

    ''' '55

  • 7/21/2019 Number Systems Lecture 2

    29/37

    utting :t 7ll Togetherutting :t 7ll Together

  • 7/21/2019 Number Systems Lecture 2

    30/37

    The &yte# Nibble# andThe &yte# Nibble# and

    ,ord,ord' byte ; bits' nibble ; 4 bits' $ord ; size de!ends on data

    !ath$ay size. ,ord size in a sim!le system may be

    one byte = bits?

    ,ord size in a C is eight bytes =4bits?

  • 7/21/2019 Number Systems Lecture 2

    31/37

    7l!hanumeri Codes7l!hanumeri Codes

    )e!resents haraters and funtionsfound on a om!uter

  • 7/21/2019 Number Systems Lecture 2

    32/37

    arity Method for 9rrorarity Method for 9rror

    DetetionDetetion&inary data and odes are fre-uently

    mo%ed bet$een loations. 8or exam!le( Digitized %oie o%er a miro$a%e lin

  • 7/21/2019 Number Systems Lecture 2

    33/37

    arity Method for 9rrorarity Method for 9rror

    DetetionDetetionThe !arity method of error detetion

    re-uires the addition of an extra bitto a ode grou!.

    This extra bit is alled the !arity bit.The bit an be either a 5 or '#

    de!ending on the number of 's inthe ode grou!.

    There are t$o methods# e%en andodd.

    Ronald Tocci/Neal Widmer/Gregory

    MossDigital Systems: Principles and

    Applications, 10e

    Copyright 2007 by Pearson Education !nc"

    Co#u$bus %& 43235

    '## rights resered"

  • 7/21/2019 Number Systems Lecture 2

    34/37

    arity Method for 9rrorarity Method for 9rror

    DetetionDetetion9%en !arity method 0 the total

    number of bits in a grou!inluding the !arity bit must add

    u! to an e%en number.The binary grou! ' 5 ' ' $ould

    re-uire the addition of a !arity bit 1' 5 ' ' Note that the !arity bit may be added at

    either end of a grou!.

    Ronald Tocci/Neal Widmer/Gregory

    MossDigital Systems: Principles and

    Applications, 10e

    Copyright 2007 by Pearson Education !nc"

    Co#u$bus %& 43235

    '## rights resered"

  • 7/21/2019 Number Systems Lecture 2

    35/37

    arity Method for 9rrorarity Method for 9rror

    DetetionDetetionGdd !arity method 0 the total

    number of bits in a grou!inluding the !arity bit must add

    u! to an odd number.The binary grou! ' ' ' ' $ould

    re-uire the addition of a !arity bit 1' ' ' '

    Ronald Tocci/Neal Widmer/Gregory

    MossDigital Systems: Principles and

    Applications, 10e

    Copyright 2007 by Pearson Education !nc"

    Co#u$bus %& 43235

    '## rights resered"

  • 7/21/2019 Number Systems Lecture 2

    36/37

    arity Method for 9rrorarity Method for 9rror

    DetetionDetetionThe transmitter and reei%er

    must @agreeA on the ty!e of!arity he

  • 7/21/2019 Number Systems Lecture 2

    37/37

    2*'5 7!!liations2*'5 7!!liations

    7 CD*)GM stores 5 megabytes ofdigital data. Ho$ many bits of data isthis

    Determine the odd !arity bit re-uiredfor eah of the follo$ing E bit 7SC::odes(

    I '55'5'5

    I 5'5''5'

    I 5''5'5'

    Determine the e%en !arity bit re-uiredfor eah E bit 7SC:: ode listed abo%e.

    Ronald Tocci/Neal Widmer/Gregory

    MossDi i l S P i i l d

    Copyright 2007 by Pearson Education !nc"

    Co#u$bus %& 43235