Hello! I have a couple questions about bit manipulation. I am working on the language C and am stuck on three short problems.

Hello! I have a couple questions about bit manipulation. I am working on the language C and am stuck on three short problems. The first one being, multiplying x by 31 using straight-line code, meaning no loops or conditionals, just these: ! ˜ & ˆ | + << >>. Mult31(void): etc. My second question was how to return an int with bits 15 and 16 set to 1 (others 0). And lastly return the count of number of 1’s in x;x being a given input. For all the problems, the rules apply for each, only straight-line code. I’ve been stuck on these for the past week or so! Help!

Leave a Reply