Question: A short value is stored in 16 bits. Write a program that prompts the user to enter a short integer and displays the 16 bits
A short value is stored in 16 bits. Write a program that prompts the user to enter a short integer and displays the 16 bits for the integer. Here are sample runs:
Enter an integer: 5
The bits are 0000000000000101
Enter an integer: –5
The bits are 1111111111111011
(Hint: You need to use the bitwise right shift operator (>>) and the bitwise AND operator (&), which are covered in Appendix G, Bitwise Operations.)
Step by Step Solution
3.49 Rating (162 Votes )
There are 3 Steps involved in it
import javautilScanner public class Exercise0544 public static v... View full answer
Get step-by-step solutions from verified subject matter experts
