Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is this a mistake in my Computer Architecture book?

I'm working on my HW for computer architecture and I came across the following problem:

A = 247
B = 237

1) Assume A and B are signed 8-bit integers stored in two's complement format. Calculate A + B using saturating arithmetic. The result should be written in decimal. Show your work.
2) Assume A and B are signed 8 bit integers stored in two's compelemnt format. Calculate A - B using saturating arithmetic.

Now, how are these even a valid questions? I know what saturating arithmetic is, but how is it valid to say that A is 247 and B is 237 when they can't be represented by an 8-bit two's complement number?

I realize the point of saturated arithmetic is in the case of a overflow/underflow to set all the bits to the extreme value but it doesn't make sense to me to ask a series of questions (there are 3 more with this same problem) involving arithmetic of numbers that can't be represented in the format they specify.

Am I wrong here?

like image 262
Teradice Avatar asked Nov 12 '09 23:11

Teradice


1 Answers

The only interpretation that makes sense is that the values given are the unsigned interpretation of the number in question; values greater than 127 are obviously out of range for an 8-bit signed twos-complement value. I agree that the question is poorly stated, however.

like image 109
bdonlan Avatar answered Sep 22 '22 20:09

bdonlan