Separate names with a comma.
Discussion in 'Mac Programming' started by mmmdreg, May 25, 2008.
Can you give any more information? Have you reassigned the item after using the AND?
A code snippet would be handy o diagnose this problem
He had code earlier I guess he has fixed his problem and edited out his original post.
When I read the post earlier I was on my phone and didn't want to try to type everything out there.
Essentially the issue appeared to be sign extension. The highest bit of the uint8 was a 1, so the sign got extended to the higher order bytes when cast to a 32-bit int. The result would have varied in other test cases, as the 0 sign bit extension wold have "looked different".
Essentially, however, you should have gotten the same numerical result (though signed, not unsigned) no matter what, as in 2s complement sign extension will not modify the value. You had wanted your uint8 to be unsigned, but turning it into an int and not an unsigned int caused the issues you saw.
It seems like you figured it out already, but wanted to toss this out there for others that might read the thread.
In the future when you resolve something it might be nicer to leave the post and add the solution in the edit or a new post for others to learn from. I don't think it was a silly question and I'm sure others will run into something similar at some point.