210 u decimal decimal hex 0 3 8 a f hex 232

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

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: yield a different result than the comparison x-y < 0. These properties are artifacts of the finite nature of computer arithmetic. Understanding the nuances of computer arithmetic can help programmers write more reliable code. 2.3.1 Unsigned Addition Consider two nonnegative integers Ü and Ý , such that ¼ Ü Ý ¾Û ½. Each of these numbers can be represented by Û-bit unsigned numbers. If we compute their sum, however, we have a possible range ¼ Ü·Ý ¾Û·½ ¾. Representing this sum could require Û ·½ bits. For example, Figure 2.14 shows a plot of the function Ü · Ý when Ü and Ý have four-bit representations. The arguments (shown on the horizontal axes) range from 0 to 15, but the sum ranges from 0 to 30. The shape of the function is a sloping plane. If we were to maintain the sum as a Û · ½ bit number and add it to another value, we may require Û · ¾ bits, and so on. This continued “word size inflation” means we cannot place any bound on the word size required to fully represent the results of arithmetic operations. Some programming languages, such as Lisp, actually su...
View Full Document

Ask a homework question - tutors are online