Unformatted text preview: ems to work on a variety of machines, however. We assume that the value 1e400 overﬂows to inﬁnity.
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 ﬂoating-point 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 ﬂoating-point approximation of ¾ . ¿ G. (d >= 0.0) || ((d*2) < 0....
View Full Document