DATA REPRESENTATION. Digital computers store information in binary Binary allows two states * On yes true 1 * Off no false 0 Each digit in a binary number is called a bit 0 1 1 0 bit 0ff 0n 0n 0ff
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation
Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement.Téléchargez la présentation en cliquant sur ce lien.Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.
F I N
Plus de contenu associé
Transcription de la présentation
DATA REPRESENTATION Digital computers store information in binary Binary allows two states * On yes true 1 * Off no false 0 Each digit in a binary number is called a bit 0 1 1 0 bit 0ff 0n 0n 0ff Binary number system == how numbers can be processed in binary IT221
Binary Numbers • Digits are 1 and 0 1 = true 0 = false • MSB – most significant bit • LSB – least significant bit • Bit numbering: IT221
Number system • A number system of base (radix) r is a system that uses distinct symbol for r digits. • Numbers are represented by a string of digit symbols. IT221
Number system • The base of a number is usually specified as a subscript, e.g.: • (01000011)2, • (71203)8, • (FF078ABC)16, ...etc. • Or a letter indicating the base (d for decimal, b for binary, o for octal and h for hexadecimal) is appended to the number, e.g.: • 01000011b, • 71203o, • FF078ABCh, ...etc. IT221
Number system • The value of a digit depends not only on its value but also on its position within the number → gives the power of the radix by which it is multiplied. IT221
Example 2 10 -1 -2 • 379.25= 3*10 + 7*10 + 9*10+2*10+5*10 n n-1 • (dndn-1...d0.f1f2…fm)r = dn* ( r ) + dn-1* ( r ) +….+ 0 -1 -2 -m d0* ( r ) + f1* ( r ) + f2* ( r ) +…+ fm* ( r ) Converting to decimal IT221
Examples on converting from different bases to Decimal Convert the following to Decimal: • (1001001)2 • (203)8 • (FA07)16 Solution: • (1001001)2 = 1 + 0*21 + 0*22 + 1*23 + 0*24 + 0*25 + 1*26 = 73d • (203)8 = 3 + 0*81 + 2*82 = 131d • (FA07)16 = 7 + 0*161 + 10*162 + 15*163 = 64007d IT221
Conversion from decimal • The conversion of a decimal integer into a base r is done by: • Whole numbers: divisions by r • Fractions: repeated multiplication by r. IT221
Conversion from decimal To convert from decimal to any numbering system with base r : • The decimal number is divided by r, • Keeping the remainder aside, the result is further divided by r, and the new remainder is kept aside, • The new result is divided again by r, and so on till the result is less than r and this would be the last remainder, • The remainders make up the equivalent base-r number, with the last remainder being the most-significant digit and the first remainder being the least-significant digit. IT221
Conversion to binaryWhole number • Ex.: (67)10 = (?)2 2 67 2 33 rem 1 LSB 2 16 rem 1 2 8 rem 0 2 4 rem 0 67d= 10000112 2 2 rem 0 2 1 rem 0 0 rem 1 MSB IT221
Octal and Hexadecimal number systems • Binary numbers are long. • On average, it takes about 3.3 times as many digits to represent a value in binary as it does to represent the same value in decimal. IT221
Octal and Hexadecimal number systems If a base R1 is an integral power of d another base R2 i.e. R1= R2 → Group of d digits in base R2 maps directly into one digit in base R1 And each digit in base R1 maps directly into d digits in base R2. IT221
Octal number systems 3 Base = 8 = 2 → d = 3 Digits: 0 → 7 Binary to Octal conversion: Group every 3 bits (starting from the right) Replace them by their corresponding octal digit Ex.: ( 0 1 0 1 1 0 1 0 1 )2 = ( 265 )8 ( 1 0 0 0 1 )2 = ( 21 )8 IT221
Octal to binary conversion • Replace each digit by its 3-bit binary equivalent. • Ex.: (476)8 = (100111110)2 IT221
Representation of signed binary numbers • Given a fixed number of bit positions (n), we n can represent 2 patterns: From (00..0)2 to (11..1)2. • Using unsigned numbers we can represent n 0 → 2 -1 n • Using signed numbers → 2 positive & negative patterns IT221
Complementary notations • The most commonly used way of representing signed numbers. It greatly simplifies all arithmetic operations. • Positive number is represented as it is (like an unsigned positive number). • Negative numbers are represented by the complement of unsigned number. IT221
Complementary notations • The value used for complementation is a power of the base or less one than a power of the base. • For binary numbers: we have 2’s complement and 1’s complement. • For decimals, we have 10’s complement and 9’s complement. • For hex. Numbers we have 16’s complement and F’s (15’s) complement. IT221
One’s complement • Is obtained by subtracting the number from (11..1)2 (n 1’s) → reversing each bit: changing every 1 to 0 and every 0 to 1. • Ex.: represent +(14d), -(14d) in 8-bit binary number • (+14)10 = ( 00001110)2 = (00001110)1s • (-14)10 = -( 00001110)2 = (11110001)1s IT221
For 8-bits number system: • Largest positive number: 0 1111111 = +(127)10 • smallest negative number: 1 0000000 = - (127)10 • Zeroes: 0 0000000 1 1111111 • Range: m-1 m-1 - (2 -1) to + 2 -1 (m : the number of bits) • -(127)10 to +(127)10 • The most significant bit represents the sign: 0 = +ve ; 1 = -ve. IT221
2’s complement • Take the 1’s complement and add 1 → invert all the bits and add 1. • Ex.: 2’s complement of (01110100)2: 1’s complement = (10001011)2 add 1 → 2’s complement = (10001100)2 IT221
2’s complement • 2’s complement of (00000000)2: 1’s complement = (11111111)2 add 1 → (100000000)2 • 2’s complement of n-bit number include only the rightmost n bits: 2’s complement of (00000000)2 = (00000000)2 IT221
2’s complement - For 8-bit binary numbers 2’s complement of (5)d = (00000101)2: 1’s complement = (11111010)2 add 1→ (11111011)2 510 + (-5)10 → 000001012 + 111110112 = 1000000002 Carry 2’s complement of any N integer represents –N: N + (-N) = 0 IT221
2’s complement • To find the 2’s complement of a binary number, proceeding from right to left, leave all bits unchanged up to and including the first `1`. Reverse all the remaining bits. • Range of signed value that can be represented in 2’s complemented notation is m-1 m-1 - 2 to 2 -1 IT221
For 8-bits number system: • Largest positive number: 0 1111111 = +(127)10 • smallest negative number: 1 0000000 = - (128)10 • Zero: 0 0000000 • Range: -(128)10 to +(127)10 • The most significant bit represents the sign: • 0 = +ve ; 1 = -ve. IT221
2’s complement in hexadecimal • Each group of four bits corresponds to a single hexadecimal digit. • Subtract each hexadecimal digit from F and then add 1 (equivalent of taking the 16’s complement). IT221
Comparing 2’s complement numbers Check the signs: If they differ, they determine the order If they are the same, the order of the numbers is the same as that of their representations. IT221
Signed binary arithmetic Overflow • Signed binary numbers are of a fixed range. • If the result of addition/subtraction goes beyond this range, overflow occurs. • Two conditions under which overflow can occur are: (i) positive add positive gives negative (ii) negative add negative gives positive IT221
2s complement addition Algorithm: • Perform binary addition on the two numbers. • Ignore the carry out of the MSB. • Check for overflow: Overflow occurs if the carriers into and out of the MSB are different. IT221
Connexion au compte
Connectez-vous pour publier votre contenu sur SlideServe.