Thread: Ch 2 - Ex 2
View Single Post
  #1 (permalink)  
Old December 29th, 2007, 08:47 PM
jkiernander jkiernander is offline
Registered User
 
Join Date: Dec 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ch 2 - Ex 2

The solution given to this in the Word document seems to provide the quotient * 8 rather than the remainder.

So for the example of 29 the solution provided ((number >> 3) << 3) gives 24 rather than 5:

11101 >> 3 = 00011 (3)

00011 << 3 = 11000 (24)

I believe a correct solution would be (number & 7):

11101 (29)
&&&&&
00111 (7)
=====
00101 (5)