Sie sind auf Seite 1von 4

COMPUTER ARCHITECTURE-EED109

CHAPTER 2-INTERNAL REPRESENTATION I. Computers store all information as a sequence of bits. - A computer is a digital electronic machine. - A computer uses two voltage levels to represent information. A high voltage and a low voltage. - A bit is a binary digit. This means it can have one of two values, 1 (high voltage) or 0 (low voltage). .- Bits are organized into bytes. 8 bits = 1 byte. - Bytes are organized into words: on a 32-bit machine a word is 32 bits or 4 bytes; on a 16-bit machine a word is 16 bits or 2 bytes. II. Integer Representation A. Binary Number System

i. Humans write integers in decimal (base-10). Each digit has 10 possible values: 0 - 9 703610 = 7 x 103 + 0 x 102 + 3 x 101 + 6 x 100 ii. Computers represent integers in binary (base-2). Each digit has 2 possible values: 0 or 1 1001102 = 1 x 25 + 0 x 24 + 0 x 23 + 1 x 22 + 1 x 21 + 0 x 20 = 3210 + 410 + 210 = 3810 iii. iv. v. vi. vii. Storing 3810 in binary (base-2) requires 6 bits (binary digits). Storing this value in one byte would be 00100110. Storing the same value in two bytes would be 0000000000100110. Storing large integers in binary requires a lot of bits. The largest one-byte binary integer would be

111111112 = 25510 viii. The largest two-byte binary integer would be 11111111111111112 = 6553510 ix. The smallest two-byte binary intger would be 00000000000000002 = 010

COMPUTER ARCHITECTURE-EED109

B.

Two's Complement Number System

i. In the binary number system, a negative number requires the use of a negative sign -1001102 = -3810 ii. To distinguish positive and negative numbers, a computer uses the two's complement number system for negative numbers. iii. In this system, if the left most bit is a 0, the integer value is positive and represented in binary (base-2). iv. If the left most bit is a 1, the number is negative and the absolute value of the negative number is not in binary, but is the two's complement of the original v. To find the two's complement 1. Change each 1 to 0, and each 0 to 1. 2. Add one to the number and discard any carry bit. vi. Examples: a. Given 10101100, what integer value is represented? It is a negative integer since the left most bit is a 1, therefore find its two's complement 1. 01010011 (flip bits) 2. + 1 (add one) ----------01010100 = 6410 + 1610 + 410 = 8410 The integer value represented by 10101100 is therefore -8410. b. Given 00101100, what integer value is represented? It is a positive integer since the left most bit is a 0, therefore simple determine it binary value 00101100 = 3210 + 810 + 410 = 4410 c. How do you represent -9410? 9410 = 6410 + 1610 + 810 + 410 + 210 = 26 + 24 + 23 + 22 + 21 = 010111102

COMPUTER ARCHITECTURE-EED109

Since we want to represent a -9410, we find two's complement of 9410. 1. 10100001 (flip bits) 2. + 1 (add one) ----------10100010 The integer value -9410 is represented as 10100010. III. Floating-Point Representation A. Floating-point numbers are numbers containing fractional information. Humans write floating-point numbers in decimal (base-10). 6.3410 = 6 34/10010 = 6 x 100 + 3 x 10-1 + 4 x 10-2 B. Computers represent floating-point numbers in binary (base-2). 101.0112 = 1 x 22 + 1 x 20 + 1 x 2-2 + 1 x 2-3 = 410 + 110 + 1/410 + 1/810 = 5 3/810 C. Floating-point numbers can be expressed in two forms, fixed notation or scientific notation. Computers express floating-point numbers in scientific notation which consists of a mantissa, base, and exponent. For example, in the floating-point number 6.02 x 1023 6.02 is the mantissa, 10 is the base, and 23 is the exponent. D. Computers store the scientific notation of the number in three pieces: a sign bit, an exponent, and a mantissa. In 16-bits for example, a floating point number could be stored as a sign bit, 5 exponent bits, and 10 mantissa bits. The base is not stored because it is given to be 2. A sign bit of 0 is means positive, and 1 means negative. The exponent is simply an integer (positive or negative), and the mantissa is stored in the remainder where left most mantissa bit may not be 0. E. To store a floating-point number, the fixed notation of form of the base-10 representation is converted to base-2. The base-2 fixed notation is then changed to scientific notation. The scientific notation is adjusted so the binary point (similar to the decimal point in base-10) is left of the most significant digit in the mantissa. The resulting base-2 exponent and mantissa are then stored by the computer.

COMPUTER ARCHITECTURE-EED109

F. How do you store 13.12510? 1. Convert fixed notation base-10 to base-2 13.62510 = 810 + 410 + 110 + 1/210 + 1/810 = 23 + 22 + 20 + 2-1 + 2-3 = 1101.1012 2. Change base-2 fixed notation to scientific notation 1101.1012 = 1101.101 x 20 3. Move binary point to the left 1101.101 x 20 = .1101101 x 24 4. Store sign bit, exponent, and mantissa 0 00100 1101101000 G. Many floating point numbers cannot be represented exactly since there are a finite number of bits used to store the mantissa. For example the following base-2 floating point number could not be store exactly in our 16-bit format: 10100110.10011110101010100100111110101 It would be truncated to 0100110.10 and stored as 1010011010 x 28

Das könnte Ihnen auch gefallen