Unformatted text preview: ems to work on a variety of machines, however. We assume that the value 1e400 overﬂows to inﬁnity.
code/data/ieee.c
1 2 3 #define POS_INFINITY 1e400 #define NEG_INFINITY (POS_INFINITY) #define NEG_ZERO (1.0/POS_INFINITY) code/data/ieee.c Problem 2.28 Solution: [Pg. 79] Exercises such as this one help you develop your ability to reason about ﬂoating point operations from a programmer’s perspective. Make sure you understand each of the answers. A. x == (int)(float) x No. For example when x is ÌÅ Ü . B. x == (int)(double) x Yes, since double has greater precision and range than int. C. f == (float)(double) f Yes, since double has greater precision and range than float. D. d == (float) d No. For example when d is 1e40, we will get ·½ on the right. E. f == (f) Yes, since a ﬂoatingpoint number is negated by simply inverting its sign bit. F. 2/3 == 2/3.0 No, the left hand value will be the integer value 0, while the right hand value will be the ﬂoatingpoint approximation of ¾ . ¿ G. (d >= 0.0)  ((d*2) < 0....
View
Full
Document
This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.
 Spring '10
 Schultz
 The American, Gulliver's Travels, 2.2.5 2.2.6 2.2.7 2.3 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5

Click to edit the document details