Unformatted text preview: int binary numbers” ¢ Let's do that, using 8-‐bit ﬁxed point numbers as an example § #1: the binary point is between bits 2 and 3 b7 b6 b5 b4 b3 [.] b2 b1 b0 § #2: the binary point is between bits 4 and 5 b7 b6 b5 [.] b4 b3 b2 b1 b0 ¢ The posi-on of the binary point aﬀects the range and precision of the representa-on § range: diﬀerence between largest and smallest numbers possible § precision: smallest possible diﬀerence between any two numbers Frac-onal Values University of Washington Fixed Point Pros and Cons ¢ Pros § It's simple. The same hardware that does integer arithme=c can do ﬁxed point arithme=c § In fact, the programmer can use ints with an implicit ﬁxed point § ints are just ﬁxed point numbers with the binary point to the right of b0 ¢ Cons § There is no good way to pick where the ﬁxed point should be § Some=mes you need range, some=mes you need precision – the more you have of one, the less of the other. Frac-onal Values University of Washington Integer & Floa-ng Point Numbers ¢
¢ Representa-on of integers: unsigned and signed Unsigned and signed integers in C Arithme-c and shiBing Sign extension Background: frac-onal binary numbers IEEE ﬂoa-ng-‐point standard Floa-ng-‐point opera-ons and rounding Floa-ng-‐point in C IEEE Floa-ng Point Standard University of Washington IEEE Floa-ng Point ¢ Analogous to scien-ﬁc nota-on § Not 12000000 but 1.2 x 107; not 0.0000012 but 1.2 x 10-‐6 § ¢ (write in C code as: 1.2e7; 1.2e-‐6) IEEE Standard 754 § Established in 1985 as uniform standard for ﬂoa=ng point arithme=c Before that, many idiosyncra=c formats § Supported by all major CPUs today § ¢ Driven by numerical concerns § Standards for handling rounding, overﬂow, underﬂow § Hard to make fast in hardware but numerically well-‐behaved ¢ 1989 Turin...
View Full Document
- Fall '09
- Exponential Function, Exponentiation, University of