1 / 18

Computer Organization and ASSEMBLY LANGUAGE

Computer Organization and ASSEMBLY LANGUAGE. Lecture 7 & 8 Floating Point Representation Binary Coded Decimal Course Instructor: Engr. Aisha Danish. Real Numbers. Numbers with fractions Could be done in pure binary 1001.1010 = 2 4 + 2 0 +2 -1 + 2 -3 =9.625

Download Presentation

Computer Organization and ASSEMBLY LANGUAGE

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Computer Organization and ASSEMBLY LANGUAGE Lecture 7 & 8 Floating Point Representation Binary Coded Decimal Course Instructor: Engr. Aisha Danish

  2. Real Numbers • Numbers with fractions • Could be done in pure binary • 1001.1010 = 24 + 20 +2-1 + 2-3 =9.625 • Where is the binary point? • Fixed? • Very limited • Moving? • How do you show where it is?

  3. Floating point • In computing, floating point describes a method of representing an approximation of a real number in a way that can support a wide range of values • The numbers are, in general, represented approximately to a fixed number of significant digits (the significand) and scaled using an exponent • The term floating point refers to the fact that a number's radix point (decimal point, or, more commonly in computers, binary point) can "float"; that is, it can be placed anywhere relative to the significant digits of the number • Floating point can be thought of as a computer realization of scientific notation

  4. How floating-point numbers work? The idea is to compose a number of two main parts: • A significand that contains the number’s digits. • Negative significands represent negative numbers. • An exponent that says where the decimal (or binary) point is placed relative to the beginning of the significand. • Negative exponents represent numbers that are very small (i.e. close to zero). Such a format satisfies all the requirements: • It can represent numbers at widely different magnitudes (limited by the length of the exponent) • It provides the same relative accuracy at all magnitudes (limited by the length of the significand)

  5. Floating Point • A typical 32-bit floating-point format • The leftmost bit stores the sign of the number • The exponent value is stored in the next 8 bits • The representation used is known as a biased representation • A fixed value, called the bias, is subtracted from the field to get the true exponent value • Typically, the bias equals 2^(k-1)-1where k is the number of bits in the binary exponent. In this case, the 8-bit field yields the numbers 0 through 255 • With a bias of 127(2^7-1), the true exponent values are in the range -127 to +128 • In this example, the base is assumed to be 2

  6. Floating Point Examples

  7. Signs for Floating Point • Mantissa/Significand is stored in 2s compliment • Exponent is in excess or biased notation • e.g. Excess (bias) 128 means • 8 bit exponent field • Pure value range 0-255 • Subtract 127 to get correct value • Range -127 to +128

  8. Normalization • A normalized number is one in which the most significant digit of the significand is nonzero • For base 2 representation, a normalized number is therefore one in which the most significant bit of the significand is one. • The typical convention is that there is one bit to the left of the radix point • i.e. exponent is adjusted so that leading bit (MSB) of mantissa is 1 • Since it is always 1 there is no need to store it • (Scientific notation where numbers are normalized to give a single digit before the decimal point e.g. 3.123 x 103)

  9. IEEE 754 • Developed to facilitate the portability of programs from one processor to another and to encourage the development of sophisticated, numerically oriented programs • The standard has been widely adopted and is used on virtually all contemporary processors and arithmetic coprocessors • 32 and 64 bit standards • 8 and 11 bit exponent respectively

  10. IEEE 754 Formats

  11. Required Reading • Stallings Chapter 9 • IEEE 754 on IEEE Web site

  12. The 8421 BCD Code • BCD stands for Binary-Coded Decimal. • A BCD number is a four-bit binary group that represents one of the ten decimal digits 0 through 9. Example: Decimal number 4926 4 9 2 6 8421 BCD coded number0100 10010010 0110

  13. QUIZ Convert the BCD coded number 1000 0111 0001 into decimal. BCD Coded Number1000 0111 0001 Decimal Number 8 7 1

  14. QUIZ Convert the decimal number 350 to its BCD equivalent. Decimal Number 3 5 0 BCD Coded Number0011 0101 0000

  15. Binary Coded Decimal (BCD) • Would it be easy for you if you can replace a decimal number with an individual binary code? • Such as 00011001 = 1910 • The 8421 code is a type of BCD to do that. • BCD code provides an excellent interface to binary systems: • Keypad inputs • Digital readouts

  16. ex2: BCD-to-dec 10000110 001101010001 1001010001110000 Binary Coded Decimal ex1: dec-to-BCD • 35 • 98 • 170 • 2469 Note: 1010, 1011, 1100, 1101, 1110, and 1111 are INVALID CODE!

  17. BCD Addition • BCD is a numerical code and can be used in arithmetic operations. Here is how to add two BCD numbers: • Add the two BCD numbers, using the rules for basic binary addition. • If a 4-bit sum is equal to or less than 9, it is a valid BCD number. • If a 4-bit sum > 9, or if a carry out of the 4-bit group is generated it is an invalid result. Add 6 (0110) to a 4-bit sum in order to skip the six the invalid states and return the code to 8421. If a carry results when 6 is added, simply add the carry to the next 4-bit group.

  18. BCD Addition • Add the following numbers (a) 0011+0100 (b) 00100011 + 00010101 (c) 10000110 + 00010011 (d) 010001010000 + 010000010111 (e) 1001 + 0100 (f) 1001 + 1001 (g) 00010110 + 00010101 (h) 01100111 + 01010011

More Related