324_Book

# 0 on most machines while 3141e201e20 will evaluate to

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: associative and commutative, so that computing all of the following C expressions yields 884,901,888: (500 ((500 ((200 400 * 400) * (300 * 200) * 400) * 300) * 200 * 500) * 300) * 400 * (200 * (300 * 500)) The computer might not generate the expected result, but at least it is consistent! Floating point arithmetic has altogether different mathematical properties. The product of a set of positive numbers will always be positive, although overﬂow will yield the special value ·½. On the other hand, ﬂoating point arithmetic is not associative due to the ﬁnite precision of the representation. For example, the C expression (3.14+1e20)-1e20 will evaluate to 0.0 on most machines, while 3.14+(1e201e20) will evaluate to 3.14. By studying the actual number representations, we can understand the ranges of values that can be represented and the properties of the different arithmetic operations. This understanding is critical to writing programs that work correctly over the full range of numeric values and that are portable...
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