Vous êtes sur la page 1sur 32

THE Alphanumeric REPRESENTATION

The data entered as characters, number digits, and punctuation are known as alphanumeric data. 3 alphanumeric codes are in common use.
ASCII (American Standard Code for Information Interchange) Unicode EBCDIC (Extended Binary Coded Decimal Interchange Code).

The following tables show the comparisons between the ASCII code in binary and hexadecimal for the given characters.

Character A B C D E F G H I J K
Space Full stop ( + $

Binary 100 0001 100 0010 100 0011 100 0100 100 0101 100 0110 100 0111 100 1000 100 1001 100 1010 100 1011
010 010 010 010 010 0000 1110 1000 1011 0100

Hex 41 42 43 44 45 46 47 48 49 4A 4B
20 2E 28 2B 24

BCD (Binary Coded Decimal) is often used to represent decimal number in binary.

Decimal 0 1 2 3 4 5 6 7 8 9

BCD 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001

Binary numbers may either signed or unsigned Oddly, CPU performs arithmetic and comparison operations 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 value between 0 - 255 for 16-bit storage location : store unsigned integer value between 0 - 65535

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

For negative numbers, there are several ways used to represent it in binary form, depending on the process take place : i. Sign-and-magnitude representation ii. 1s complement representation iii. 2s complement representation

In daily usage, signed integers are represented by a plus or minus sign 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 considered the sign bit. The remaining (n-1) bits are used for magnitude.

Example 1 :
+ 0010 0101 (+37) 1010 0101 (-37) 0000 0000 0000 0001 (+1) 1000 0000 0000 0001 (-1) 0111 1111 1111 1111 (+32767) 1111 1111 1111 1111 (-32767)

Example 2 : What is the sign-and-magnitude representation of the decimal numbers 31 and +31 if the basic unit is a byte ?
3110 = 111112 Unit is a byte = 8 bits

+31 -31

= =

0 1

0 0

0 0

1 1

1 1

1 1

1 1

1 1

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

+3 = 0000 1 -3 = 1000 1

0000 0000

0001 0001

1111 1111

Example 4 : What is the decimal equivalent value of the signand -magnitude binary sequence 1011 1001 ?

Sign is negative 11 10012 = 5710 1011 10012 = - 5710

Addition of 2 numbers in sign-andmagnitude :


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.

Example 5 : What is the decimal value of the sum of the binary numbers 00100110 and 00011110 if they are represented in sign-andmagnitude ? Assume that the basic unit is the byte. Same signs : magnitude are added

1 1 1

1 1

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

0 1 1 0 1 1 1 0 0 1 0 0

Sign is positive 100 01002 = 6810 0100 01002= +6810

Example 6 : What is the decimal value of the sum of the binary numbers 10110011 and 00010110 if they are represented in sign-andmagnitude ? Assume that the basic unit is the byte. Different signs : Larger magnitude - smaller magnitude Larger magnitude : 1011 0011 2 Smaller magnitude : 0001 0110 Sign is negative 0 0 1 2 111012 = 2910 1 0 1 1 0 0 1 1 1001 11012 = 2910 - 0 0 0 1 0 1 1 0

1 0 0 1

1 1 0 1

1S Complement Convention

In base 2, the largest digit is 1. The 1s complement is performed simply by changing:


every 0 every 1

1 and 0.

Also known as inversion

2S Complement Convention

Most popular among computer manufacturers since it does not present any of the problems 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-1 1)

Notice that 1111 the range of negative numbers is one larger than the range of0000 the positive 0111 0000 0000 1111 1111 1000 values

(127)

(0)

(-1)

(-128)

( 2n-1 1)

- (2n)

2S Complement Convention

To represent a negative number in this convention, follow the 3 steps 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 complement number 11100011 ?

2S Complement Convention

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

Step:

23 in binary 1s (inverse)
2s 2s complement representation +

0 1

0 1

0 1

1 0

0 1

1 0

1 0

1 0 1

2S Complement Convention

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

Step:

2s complement representation
1s (inverse) 2s Decimal positive value +

1 0 0

1 0 0

1 0 0

0 1 1

0 1 1

0 1 1

1 0 0

1 0 1 1

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 fractions floating point method involves splitting the fraction into two parts, an exponent and a mantissa Computer industry agreed upon a standard for the storage of floating point numbers the IEEE 754 standard; uses 32 bits of memory (single precision) or 64 bits (double precision)

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


Total number of bits : 1 Sign 8 Biased exponent 23 Mantissa (fraction)

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


Total number of bits :
1 Sign 11 Biased exponent 52 Mantissa (fraction)

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

Convert to binary Put into 1.xxxx X 2y Biased exponent Sign Significand Mantissa

153.75 = 1001 1001.112 = 1.0011 0011 12 x 27 Exponent = 7 Biased exponent Sign = +ve (0) Significand = 1.0011 0011 1 Mantissa = 001 1001 1100 0000 0000 0000 (23bits) IEEE format : = 127 + y = 127 + 7 = 134 = 1000 01102 (8 bits)

Sign
IEEE format 0

Biased Exponent
1000 0110

Mantissa (23)
001 1001 1100 0000 0000 0000
1001 9 1100 C 0000 0 0000 0 0000 0

0100 Hexadecimal 4

0011 3

0001 1

= 4319 C000 h

Convert to binary Put into 1.xxxx X 2y Biased exponent Sign Significand Mantissa

29 / 128

= 111012 / 27 = 1.11012 x 24 x 2-7

= 111012 x 2-7 = 1.11012 x 2-3

Exponent = -3 Biased exponent Sign = -ve

= 127 + y = 127 + (-3) = 124 = 0111 11002 (8 bits) =1

Significand = 1.1101 Mantissa = 110 1000 0000 0000 0000 0000 (23bits) IEEE format : Sign

IEEE format 1

Biased Exponent 0111 1100

Mantissa (23) 110 1000 0000 0000 0000 0000


1000 8 0000 0 0000 0 0000 0 0000 0

1011 Hexadecimal B

1110 E

0110 6

= BE68 0000 h

Convert C2F0 000016 in IEEE floating point format to the decimal number.

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

In hexadecimal Convert to binary

C2F0000016 C 1100 2 0010 F 1111 0 0000 0 0000 0 0000 0 0000 0 0000

IEEE format :
Put into IEEE format Sign Biased Exponent Mantissa (23)

1
Get the biased exponent Sign Mantissa Significand Put into 1.xxxx X 2y The actual number

1000 0101

111 0000 0000 0000 0000 0000

Biased Exponent:: 1000 0101 = 133 Exponent : 133 127 = 6 1 = -ve 111 0000 0000 0000 0000 0000 1.111 1.111 x 26 =1111 0002 = 12010 - 120

1.

2.

3.
4.

5.

Convert 132.510 to floating point numbers in IEEE single precision format. Give the answer in hexadecimal. What is the decimal number equivalent to the following IEEE single precision floating point given in hexadecimal 40B1000016? Represent the decimal value 153.75 using 32-bit IEEE single-precision format in hexadecimal form. What is the IEEE single precision floating point representation for the decimal number of - 22.25? Give the result in hexadecimal. Convert C2F0000016 IEEE single precision floating point number to its decimal value.