+ All Categories
Home > Documents > Machine Level Representation of Data Part 3 (1)

Machine Level Representation of Data Part 3 (1)

Date post: 03-Apr-2018
Category:
Upload: zainulsyafiq-ank-en-din
View: 231 times
Download: 0 times
Share this document with a friend

of 32

Transcript
  • 7/28/2019 Machine Level Representation of Data Part 3 (1)

    1/32

    THE Alphanumeric REPRESENTATION

  • 7/28/2019 Machine Level Representation of Data Part 3 (1)

    2/32

    The data entered as characters, numberdigits, and punctuation are known asalphanumeric data.

    3 alphanumeric codes are in common use. ASCII (American Standard Code for Information

    Interchange)

    Unicode

    EBCDIC (Extended Binary Coded Decimal

    Interchange Code).

  • 7/28/2019 Machine Level Representation of Data Part 3 (1)

    3/32

    The followingtables show

    thecomparisonsbetween theASCII code in

    binary andhexadecimalfor the givencharacters.

    Character Binary HexA 100 0001 41B 100 0010 42C 100 0011 43D 100 0100 44E 100 0101 45F 100 0110 46G 100 0111 47H 100 1000 48I 100 1001 49

    J 100 1010 4A

    K 100 1011 4B

    Space 010 0000 20Full stop 010 1110 2E

    ( 010 1000 28+ 010 1011 2B$ 010 0100 24

  • 7/28/2019 Machine Level Representation of Data Part 3 (1)

    4/32

  • 7/28/2019 Machine Level Representation of Data Part 3 (1)

    5/32

    BCD (BinaryCoded Decimal)

    is often used torepresentdecimal numberin binary.

    Decimal BCD0 0000

    1 00012 00103 00114 01005 0101

    6 01107 01118 10009 1001

  • 7/28/2019 Machine Level Representation of Data Part 3 (1)

    6/32

  • 7/28/2019 Machine Level Representation of Data Part 3 (1)

    7/32

    Binary numbers may either signedor unsigned

    Oddly, CPU performs arithmetic and comparisonoperations for both type equally well, without knowing

    which type its operating on. An unsigned numbers:

    numbers with only positive values

    for 8-bit storage location : store unsigned integer valuebetween 0 - 255

    for 16-bit storage location : store unsigned integer valuebetween 0 - 65535

    Unsigned number can be converted directly to binarynumbers and processed without any special care

  • 7/28/2019 Machine Level Representation of Data Part 3 (1)

    8/32

    For negative numbers, there are several ways usedto represent it in binary form, depending on the

    process take place :i. Sign-and-magnitude representation

    ii. 1s complement representation

    iii. 2s complement representation

  • 7/28/2019 Machine Level Representation of Data Part 3 (1)

    9/32

    In daily usage, signed integers are represented bya plusor minussign and a value.

    In the computer, the uses of 0s and 1s take place. 0 : plus ( positive)

    1 : minus (negative)

    The leftmost bit in a binary number is consideredthe sign bit.

    The remaining (n-1) bits are used for magnitude.

  • 7/28/2019 Machine Level Representation of Data Part 3 (1)

    10/32

    Example 1 :

    + 0010 0101

    (+37)

    0000 0000 0000 0001

    (+1)

    0111 1111 1111 1111

    (+32767)

    - 1010 0101

    (-37)

    1000 0000 0000 0001

    (-1)

    1111 1111 1111 1111

    (-32767)

  • 7/28/2019 Machine Level Representation of Data Part 3 (1)

    11/32

    Example 2 :

    What is the sign-and-magnitude representation ofthe decimal numbers 31 and +31 if the basic unit

    is a byte ? 3110 = 111112 Unit is a byte = 8 bits

    +31 = 0 0 0 1 1 1 1 1-31 = 1 0 0 1 1 1 1 1

  • 7/28/2019 Machine Level Representation of Data Part 3 (1)

    12/32

    Example 3 :What is the sign-and-magnitude representation of thedecimal numbers 31 and +31 if the basic unit is a word? 3110 = 111112 Unit is a word= 16 bits

    +31 = 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1-31 =1000 0000 0001 1111

  • 7/28/2019 Machine Level Representation of Data Part 3 (1)

    13/32

    Example 4 :

    What is the decimal equivalent value of the sign-and -magnitude binary sequence 1011 1001 ?

    1 0 1 1 1 0 0 1 Sign is negative

    11 10012 = 57101011 10012 = - 5710

  • 7/28/2019 Machine Level Representation of Data Part 3 (1)

    14/32

    Addition of 2 numbers in sign-and-magnitude :

    using the usual conventions of binary arithmetic if both have same sign: magnitude are added

    and the same sign copied

    if the sign different: number that has smaller

    magnitude is subtracted from the larger one.The sign is copied from the larger magnitude.

  • 7/28/2019 Machine Level Representation of Data Part 3 (1)

    15/32

    Example 5 :

    What is the decimal value of the sum of the binary numbers00100110 and 00011110 if they are represented in sign-and-

    magnitude ? Assume that the basic unit is the byte. Same signs : magnitude are added

    1 1 1 1 1 Sign is positive

    100 01002 = 68100100 01002=+6810

    0 0 1 0 0 1 1 0+ 0 0 0 1 1 1 1 0

    0 1 0 0 0 1 0 0

  • 7/28/2019 Machine Level Representation of Data Part 3 (1)

    16/32

    Example 6 :

    What is the decimal value of the sum of the binary numbers10110011 and 00010110 if they are represented in sign-and-

    magnitude ? Assume that the basic unit is the byte. Different signs : Larger magnitude - smaller

    magnitude

    Larger magnitude : 1011 0011

    Smaller magnitude : 0001 0110020 1 2 Sign is negative

    111012 = 29101001 11012 = -2910

    1 0 1 1 0 0 1 1- 0 0 0 1 0 1 1 0

    1 0 0 1 1 1 0 1

  • 7/28/2019 Machine Level Representation of Data Part 3 (1)

    17/32

  • 7/28/2019 Machine Level Representation of Data Part 3 (1)

    18/32

    In base 2, the largest digit is 1.

    The 1s complement is performed simply bychanging: every 0 1 and

    every 1 0.

    Also known as inversion

    1S Complement Convention

  • 7/28/2019 Machine Level Representation of Data Part 3 (1)

    19/32

  • 7/28/2019 Machine Level Representation of Data Part 3 (1)

    20/32

    Most popular among computer manufacturers since it does not present any of theproblems of the sign-and-magnitude or 1s complement.

    Positive numbers : using similar procedure as sign-and-magnitude

    Given n bits, the range of numbers that can be represented in 2s complement is

    ((2n )) to (2n-11)

    Notice that the range of negative numbers is one larger than the range of the positivevalues

    2S Complement Convention

    0111 1111

    (127)

    0000 0000

    (0)

    1111 1111

    (-1)

    1000 0000

    (-128)

    ( 2n-11) - (2n)

  • 7/28/2019 Machine Level Representation of Data Part 3 (1)

    21/32

    To represent a negative number in this convention, follow the 3steps process below:

    Step 1 : Express the absolute value of the number in binary

    Step 2 : Change all 0s to 1s and vise versa

    1s complement Step 3 : Add 1 to the binary number of step 2

    Example 1 :

    What is the 2s complement representation of-23 ?

    Example 2 :

    What is the decimal positive value of the 2s complementnumber 11100011 ?

    2S Complement Convention

  • 7/28/2019 Machine Level Representation of Data Part 3 (1)

    22/32

    Example 1 :What is the 2s complement representation of-23 ?

    2S Complement Convention

    Step:23 in binary 0 0 0 1 0 1 1 11s (inverse) 1 1 1 0 1 0 0 02s + 12s complementrepresentation

    1 1 1 0 1 0 0 1

  • 7/28/2019 Machine Level Representation of Data Part 3 (1)

    23/32

    Example 2 :What is the decimal positive value of the 2s complementnumber 11100011 ?

    2S Complement Convention

    Step:2s complementrepresentation

    1 1 1 0 0 0 1 1

    1s (inverse) 0 0 0 1 1 1 0 02s + 1Decimal positive value 0 0 0 1 1 1 0 1

  • 7/28/2019 Machine Level Representation of Data Part 3 (1)

    24/32

  • 7/28/2019 Machine Level Representation of Data Part 3 (1)

    25/32

    2 problems with integers;

    They cant express fractions, AND

    The range number is limited to the number of bits used. An efficient way of storing fractionsfloating point method

    involves splitting the fraction into two parts, an exponentand

    a mantissa

    Computer industry agreed upon a standard for the storage offloating point numbers

    the IEEE 754 standard; uses 32 bits of memory (single

    precision) or 64 bits (double precision)

  • 7/28/2019 Machine Level Representation of Data Part 3 (1)

    26/32

    IEEE short real : 32 bits (Exponent system = excess 127)

    IEEE short real : 64 bits (Exponent system = excess 1023)

    Total number

    of bits : 1 11 52

    Sign Biased exponent Mantissa (fraction)

    Total number

    of bits : 1 8 23

    Sign Biased exponent Mantissa (fraction)

  • 7/28/2019 Machine Level Representation of Data Part 3 (1)

    27/32

    Convert 153.7510 to the IEEE floating point format.

    Step 1 : convert into binary

    Step 2 : put into 1.xxxx X 2y format

    Step 3 : get the biased exponent

    Step 4 : get the sign (from the question)

    Step 5 : identify significand and mantissa

    Step 6 : put into the IEEE single precision format

    Step 7 : convert into hexadecimal

  • 7/28/2019 Machine Level Representation of Data Part 3 (1)

    28/32

    Convert to binary 153.75 = 1001 1001.112

    Put into 1.xxxx X 2y = 1.0011 0011 12

    x 27

    Biased exponent

    Exponent = 7

    Biased exponent = 127 + y = 127 + 7 = 134

    = 1000 01102 (8 bits)

    Sign Sign = +ve (0)

    Significand

    Mantissa

    Significand = 1.0011 0011 1

    Mantissa = 001 1001 1100 0000 0000 0000 (23bits)

    IEEE format

    IEEE format :

    Sign BiasedExponent

    Mantissa (23)

    0 1000 0110 001 1001 1100 0000 0000

    0000

    Hexadecimal

    0100 0011 0001 1001 1100 0000 0000 0000

    4 3 1 9 C 0 0 0

    = 4319 C000 h

  • 7/28/2019 Machine Level Representation of Data Part 3 (1)

    29/32

    Convert to binary 29 / 128 = 111012 / 27 = 111012 x 2

    -7

    Put into 1.xxxx X 2y = 1.11012 x 24 x 2-7 = 1.11012 x 2-3

    Biased exponent

    Exponent = -3

    Biased exponent = 127 + y = 127 + (-3) = 124

    = 0111 11002 (8 bits)

    Sign Sign = -ve = 1

    Significand

    Mantissa

    Significand = 1.1101

    Mantissa = 110 1000 0000 0000 0000 0000 (23bits)

    IEEE format

    IEEE format :

    Sign BiasedExponent Mantissa (23)1 0111 1100 110 1000 0000 0000 00000000

    Hexadecimal

    1011 1110 0110 1000 0000 0000 0000 0000

    B E 6 8 0 0 0 0

    = BE68 0000 h

  • 7/28/2019 Machine Level Representation of Data Part 3 (1)

    30/32

    Convert C2F0 000016 in IEEE floating point format to the decimalnumber.

    Step 1 : in hexadecimal

    Step 2 : convert into binary

    Step 3 : put into the IEEE single precision format

    Step 4 : get biased exponent

    Step 5 : get the sign

    Step 6 : identify significand and mantissa

    Step 7 :put into 1.xxxx X 2y

    Step 8 : identify actual number

  • 7/28/2019 Machine Level Representation of Data Part 3 (1)

    31/32

    In hexadecimal C2F0000016

    Convert to binaryC 2 F 0 0 0 0 0

    1100 0010 1111 0000 0000 0000 0000 0000

    Put into IEEE format

    IEEE format :

    Sign Biased Exponent Mantissa (23)

    1 1000 0101 111 0000 0000 0000 0000 0000

    Get the biased

    exponent

    Biased Exponent:: 1000 0101 = 133

    Exponent : 133 127 = 6

    Sign 1 = -ve

    Mantissa

    Significand

    111 0000 0000 0000 0000 0000

    1.111

    Put into 1.xxxx X 2y

    1.111 x 26

    =1111 0002= 12010

    The actual number - 120

  • 7/28/2019 Machine Level Representation of Data Part 3 (1)

    32/32

    1. Convert 132.510 to floating point numbers in IEEE

    single precision format. Give the answer inhexadecimal.

    2. What is the decimal number equivalent to thefollowing IEEE single precision floating point given

    in hexadecimal 40B1000016?3. Represent the decimal value 153.75 using 32-bit

    IEEE single-precision format in hexadecimal form.

    4. What is the IEEE single precision floating point

    representation for the decimal number of - 22.25?Give the result in hexadecimal.

    5. Convert C2F0000016 IEEE single precision floatingpoint number to its decimal value.


Recommended