Question: Write a small program that takes a non-negative integer as its input and outputs two results, one having performed a single position left shift

Write a small program that takes a non-negative integer as its input and outputs two results, one having 

Write a small program that takes a non-negative integer as its input and outputs two results, one having performed a single position left shift of the input's bits and the other a single position right shift of the input's bits. Once you have it working see what the results are with a few integer inputs and answer the following questions. Include your answer to the question as a comment at the end of your code. Using the sign-magnitude bit model, shifting to the left is the same as what simple mathematical operation? How about shifting to the right? Using shell commands to produce the results one at a time, examples of the results should be: On Linux: cbe@Laptop-Curtis:~$ cbe@Laptop-Curtis:~$ 8 14 On Windows: C:\Users\ccrbu>set /a "17>>1" 8 echo $((17 >> 1)) echo $((7 < < 1)) C:\Users\ccrbu>set /a "7 <

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres a simple Python program that takes a nonnegative integer as input and performs a single positi... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!