Question
2.II.3. [5 pts] Imagine that x is an integer. It is a fact that (x < < 2) + x = cx for some integer
2.II.3. [5 pts] Imagine that x is an integer. It is a fact that (x << 2) + x = cx for some integer c. What is the value of c, and why?
2.II.4. [5 pts] Imagine that x contains a color, represented as a 24 bit integer. (x >> 8) & 0xff gives me the amount of green in the color. What do I need to do to get the amount of red in the color?
2.II.5. [5 pts] What about the amount of blue in a color?
2.II.6. [5 pts] In the negative of an image, every color is replaced by its opposite. White becomes black, black becomes white, red becomes cyan, yellow becomes blue, magenta becomes green. Imagine you have a color stored in a variable x. Imagine that some members of your team advocate using ~x to compute the negative, others advocate using 0xffffff - x. Which one is right, or does it not matter?
2.II.7. [5 pts] Let x be some integer that is represented using 32 bits. What is the result of ~x | x?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started