324_Book

# These addresses have the binary form 0 0110 0100 11xx

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

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 ﬂ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

## This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online