bit operation example from K+R vs. newlisp
Posted: Sat Sep 30, 2006 11:00 pm
I was perusing through K+R "The C Programming Language" and came across this tidbit on bit operations:

And the (p + 1 - n) doesn't make sense, as it would seem you actually want to do (p - n). I wrote the same function in newlisp both ways:
(p - n):

(p + 1 - n):

And the (p - n) is the one behaving as I would expect. What am I missing here? Am I not understanding K+R properly in their example? I couldn't imagine that this is a typo.
Any insights to clear my confusion would be greatly appreciated.
--maq

And the (p + 1 - n) doesn't make sense, as it would seem you actually want to do (p - n). I wrote the same function in newlisp both ways:
(p - n):

(p + 1 - n):

And the (p - n) is the one behaving as I would expect. What am I missing here? Am I not understanding K+R properly in their example? I couldn't imagine that this is a typo.
Any insights to clear my confusion would be greatly appreciated.
--maq