Presentation is loading. Please wait.

Presentation is loading. Please wait.

Floating Point Numbers - continuing

Similar presentations


Presentation on theme: "Floating Point Numbers - continuing"— Presentation transcript:

1 Floating Point Numbers - continuing
Dr. Clincy Professor of CS Dr. Clincy Lecture 7

2 IEEE Standards The IEEE has established a standard for floating-point numbers The IEEE-754 single precision floating point standard uses an 8-bit exponent (with a bias of 127) and a 23-bit significand. The IEEE-754 double precision standard uses an 11-bit exponent (with a bias of 1023) and a 52-bit significand. In both the IEEE single-precision and double-precision floating-point standard, the significand has an implied 1 to the LEFT of the radix point. The format for a significand using the IEEE format is: 1.xxx… For example, 4.5 = x 23 in IEEE format is 4.5 = x 22. The 1 is implied, which means the bit does not need to be listed in the significand (the significand would include only 001). Dr. Clincy Lecture 7

3 Example Example: Express as a floating point number using IEEE single precision. First, let’s normalize according to IEEE rules: 3.75 = = x 21 The bias is 127, so we add = 128 (this is our exponent) The first 1 in the significand is implied, so we have: Since we have an implied 1 in the significand, this equates to -(1).1112 x 2 (128 – 127) = x 21 = = (implied) Dr. Clincy Lecture 7

4 The Zero Issue Both the 14-bit model that we have presented and the IEEE-754 floating point standard allow two representations for zero. Zero is indicated by all zeros in the exponent and the significand, but the sign bit can be either 0 or 1. This is why programmers should avoid testing a floating-point value for equality to zero. Negative zero does not equal positive zero. Dr. Clincy Lecture 7

5 Addition and Subtracting
Floating-point addition and subtraction are done using methods analogous to how we perform calculations using pencil and paper. The first thing that we do is express both operands in the same exponential power, then add the numbers, preserving the exponent in the sum. If the exponent requires adjustment, we do so at the end of the calculation. Example: Find the sum of 1210 and using the 14-bit “simple” floating-point model. We find 1210 = x And = x 2 1 = x 2 4. Thus, our sum is x 2 4. Dr. Clincy Lecture 7

6 Multiplication Example:
Floating-point multiplication is also carried out in a manner akin to how we perform multiplication using pencil and paper. We multiply the two operands and add their exponents. If the exponent requires adjustment, we do so at the end of the calculation. Example: Find the product of 1210 and using the 14-bit floating-point model. We find 1210 = x And = x 2 1. Thus, our product is x 2 5 = x 2 4. The normalized product requires an exponent of 2210 = Dr. Clincy Lecture 7

7 Error Issue No matter how many bits we use in a floating-point representation, our model must be finite. The real number system is, of course, infinite, so our models can give nothing more than an approximation of a real value. At some point, every model breaks down, introducing errors into our calculations. By using a greater number of bits in our model, we can reduce these errors, but we can never totally eliminate them. We must also be aware that errors can compound through repetitive arithmetic operations. For example, our 14-bit model cannot exactly represent the decimal value In binary, it is 9 bits wide: = When we try to express in our 14-bit model, we lose the low-order bit, giving a relative error of: If we had a procedure that repetitively added 0.5 to 128.5, we would have an error of nearly 2% after only four iterations. 128.5  0.39% Dr. Clincy Lecture 7

8 Overflow and Underflow
Floating-point overflow and underflow can cause programs to crash. Overflow occurs when there is no room to store the high-order bits resulting from a calculation. Underflow occurs when a value is too small to store, possibly resulting in division by zero. Experienced programmers know that it’s better for a program to crash than to have it produce incorrect, but plausible, results. Dr. Clincy Lecture 7

9 Dr. Clincy Professor of CS
Ch 2 Appendix: Codes for Data Recording and Transmission Dr. Clincy Professor of CS Dr. Clincy Lecture 7

10 Codes for Data Recording and Transmission
i.e. i.e. 56 as Computer Results Digital or Analog Signals i.e. i.e. “5” & “6” as Computer Computer (Codec, Modem) Magnetic Flux reversals Codes (w/parity) Rx or Recording Medium Results to Code Encoding Computer Signal travelling across transport facility or bus Network Receiver or Magnetic Tape or Disk Data to Signal Encoding or Translation (A/A, A/D, D/A, D/D) To transmit data, pulses of “high” and “low” voltage are sent across communications media. To store data, changes are induced in the magnetic polarity of the recording medium. These polarity changes are called flux reversals. The period of time during which a bit is transmitted, or the area of magnetic storage within which a bit is stored is called a bit cell. Dr. Clincy Lecture 7

11 Data Vs Signal Fully explain the difference between signal and data before getting into the details Digital Transmission DATA SIGNAL D D A Analog Transmission A D Dr. Clincy Lecture 7

12 DIGITAL-TO-DIGITAL CONVERSION
Can represent digital data by using digital signals. The conversion involves three techniques: line coding – converting bit sequences to signals block coding – adding redundancy for error detection scrambling – deals with the long zero-level pulse issue Line coding is always needed; Block coding and scrambling may or may not be needed. Dr. Clincy Lecture 7

13 Line coding and decoding
At Tx - Digital data represented as codes is converted to a digital signal via an encoder At Rx – Digital signal is converted back to digital codes via a decoder Dr. Clincy Lecture 7

14 Signal element versus data element
Data element - smallest entity representing info Signal element – shortest unit of a digital signal (carriers) r – is the ratio of # of data elements carried per signal element Example of adding extra signal elements for synchronization Example of increasing data rate Dr. Clincy Lecture 7

15 Data Rate Versus Signal Rate
Data rate (or bit rate) - # of data elements (or bits) transmitted in 1 second – bits-per-second is the unit Signal rate (pulse rate or baud rate) - # of signal elements transmitted in 1 second – baud is the unit OBJECTIVE ALWAYS: increase data rate while decreasing signal rate – more “bang” for the “buck” Is it intuitive that if you had a data pattern of all 0s or 1s, it would effect the signal rate ? Therefore to relate data-rate with signal-rate, the pattern matters. Worst Case Scenario – we need the maximum signaling rate (alternating 1/0s) Best Case Scenario – we need the minimum signaling rate (all 1/0s) Focus on average case S = c x N x 1/r N – data rate (bps) c – case factor S - # of signal elements r – ratio of data to signal Dr. Clincy Lecture 7

16 Example A signal is carrying data in which one data element is encoded as one signal element ( r = 1). If the bit rate is 100 kbps, what is the average value of the baud rate if c is between 0 and 1? Solution We assume that the average value of c is 1/2 . The baud rate is then Dr. Clincy Lecture 7

17 Line coding scheme categories
Dr. Clincy Lecture 7


Download ppt "Floating Point Numbers - continuing"

Similar presentations


Ads by Google