KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
So I see that this question has already been asked, however the answers were a little vague and unhelpful. Okay, I need to implement a c expression using only "& ^ ~ ! + | >> <<" The expression needs to resemble: a ? b : c So, from what I've been able to tell, the expression needs to look something like: return (a & b) | (~a & c) This works when a = 0, because anding it with b will give zero, and then the or expression will return the right side, (~a & c) which works because ~0 gives all ones, and anding c with all ones returns c. However, this doesn't work when a > 0. Can someone try to explain why this is, or how to fix it?
Tags (comma-separated)
Save Edits
Cancel