Question 289 Chapter 2 Book Computer Systems Programmers Perspective Third Edition Running Q34401819

Question 2.89 (Chapter 2): (Book: Computer Systems: AProgrammers Perspective (Third edition))

We are running programs on a machine where values of type inthave a 32 bit two’s-complement representation. Values of the typefloat use the 32 bit IEEE format, and values of type double use the64 bit IEEE format.

We generate arbitrary integer values x, y, and z, and convertthem to values of type doubles as follows:

/* Create some arbitrary values */

int x = random();

int y = random();

int z = random();

/* Convert to double */

double dx = (double) x;

double dx = (double) y;

double dx = (double) z;

For each of the following C expressions, you are to indicatewhether or not the expression always yields 1. If it always yields1, describe the underlying mathematical principles. Otherwise givean example of arguments that make it yield 0. Note that you cannotuse an IA32 machine running GCC to test your answers, since itwould use 80 bit extended precision representation for both floatand double.

A. (float) x == (float) dx

B. dx – dy == (double) (x-y)

C. (dx + dy) + dz == dx * (dy + dz)

D. (dx * dy) * dz == dx * (dy * dz)

E. dx / dx == dz / dz

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *