A short value is stored in 16 bits. Write a program that prompts the user to enter
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 for the integer. Here are sample runs:
Transcribed Image Text:
Enter an integer: 5 JEnter The bits are 0000000000000101 Enter an integer: -5 J Enter The bits are 1111111111111011 Example (using bytes in the exumple) Description Operator Name 10101110 & 10010010 yields 10000010 Bitwise AND The AND of two corresponding bits yields a l if both bits are 1. 10101110 | 10010010 yields 10111110 The OR of two corresponding bits yields a 1 if either bit is 1. Bitwise inclusive OR 10101110 A 10010010 yields 00111100 The XOR of two corresponding bits yields a 1 only if two bits are Bitwise exclusive OR different. One's -10101110 yields 01010001 The operator toggles cach bit from O to I and from 1 to 0. complement 10101110 << 2 yields The operator shifts bits in the first operand left by the number of bits specified in the second operand, filling with Os on the right. << Left shift 10111000 10101110 >> 2 yields Right shift with sign extension The operator shifts bit in the first operand right by the number of bits specified in the second operand, 11101011 00101110 >> 2 yields 00001011 filling with the highest (sign) bit on the left. Unsigned right 10101110 >>> 2 yields The operator shifts bit in the first operand right by the number of bits specified in the second operand, filling with Os on the left. >>> shift with zero 00101011 extension 00101110 >>> 2 yields 00001011
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 60% (10 reviews)
Output Enter an integer 5 The 16 bits are 000000000101 Computer archi...View the full answer
Answered By
Ayush Mishra
I am a certified online tutor, with more than 3 years of experience in online tutoring. My tutoring subjects include: Physics, Mathematics and Mechanical engineering. I have also been awarded as best tutor for year 2019 in my previous organisation. Being a Mechanical Engineer, I love to tell the application of the concepts of science and mathematics in the real world. This help students to develop interest and makes learning fun and easy. This in turn, automatically improves their grades in the subject. I teach students to get prepared for college entry level exam. I also use to teach undergraduate students and guide them through their career aim.
5.00+
2+ Reviews
10+ Question Solved
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Question Posted:
Students also viewed these Computer science questions
-
Write a program that prompts the user to enter an integer for today?s day of the week (Sunday is 0, Monday is 1, ?, and Saturday is 6). Also prompt the user to enter the number of days after today...
-
Write a program that prompts the user to enter a hex digit and displays its corresponding binary number. Here is a sample run: Enter a hex digit: B JEnter The binary value is 1011 Enter a hex digit:...
-
Implement a class named BitOutputStream, as shown in Figure 17.22, for writing bits to an output stream. The writeBit(char bit) method stores the bit in a byte variable. When you create a...
-
Determine the order of growth of the running time of this statement in ThreeSum as a function of the number of integers \(n\) on standard input: int[] a = StdIn. readA11Ints(); Answer: Linear. The...
-
Determine whether each of these functions is a bijection from R to R. a) f (x) = 2x + 1 b) f (x) = x2 + 1 c) f (x) = x3 d) f (x) = (x2 + 1)/(x2 + 2)
-
Do YOU agree that criticism against general principles of organisation should be directed not against the need for such principles but the manner in which they are implemented?
-
You need to understand the approach described in question 3 in More Genetic TIPS before answering this question. A muscle-specific gene was cloned and then subjected to promoter bashing. As shown...
-
Pace Distributing Company completed the following merchandising transactions in the month of April. At the beginning of April, the ledger of Pace showed Cash of $9,000 and Owners Capital of $9,000....
-
A combined solar and auxiliary energy system is used to meet the same load as in Example 12.5. The total cost of the system to cover 65% of the load (solar fraction) is $20,000. The owner will pay a...
-
Describe the matrices and formulae used to determine centralization or distribution of data. In the absence of subjective reasoning, would the matrices and formulae lead to a rational decision? Why...
-
In business applications, you are often asked to compute the mean and standard deviation of data. The mean is simply the average of the numbers. The standard deviation is a statistic that tells you...
-
Rewrite Programming Exercise 5.39 as follows: ? Use a for loop instead of a do-while loop. ? Let the user enter COMMISSION_SOUGHT instead of fixing it as a constant. You have just started a sales job...
-
Balmer Corporations master (static) budget for the year is shown below: Required 1. During the year the company actually manufactured and sold 42,000 units of product. Prepare an Excel spreadsheet...
-
The transactions in ABC Nation last year were: arked out of 5.00 Item Dollars Wages paid to labour Consumption expenditure 425,000 Net taxes 210,000 Profits 230,000 240,000 Investment Government...
-
What is the benefit of using the lesson plan methodology in research? Explain
-
Would you recommend to a client to invest in a renewable energy company such as a wind farm or solar energy producer if you expected that it was going to provide lower short-term returns than a...
-
what is the differencebetween in formal and informal innovation management? Explain
-
Do you think having a separate capital budget process to acquire or manage large capital assets is a good approach to budgeting? Support your position with examples.
-
Recently, while eating lunch with your family at a local cafeteria, you observe a practice that is somewhat unusual. As you reach the end of the cafeteria line, an employee asks how many people are...
-
Refer to the situation described inBE 18-13, but assume a 2-for-1 stock split instead of the 5% stock dividend. Prepare the journal entry to record the stock split if it is to be effected in the form...
-
a. Create an application named Percentages whose main() method holds two double variables. Assign values to the variables. Pass both variables to a method named computePercent() that displays the two...
-
To encourage good grades, Hermosa High School has decided to award each student a bookstore credit that is 10 times the students grade point average. In other words, a student with a 3.2 grade point...
-
There are 12 inches in a foot and 3 feet in a yard. Create a class named InchConversion. Its main() method accepts a value in inches from a user at the keyboard, and in turn passes the entered value...
-
What regulatory frameworks govern the research, development, and commercialization of products derived from recombinant DNA technology, and how do they ensure safety, efficacy, and ethical standards...
-
How will MBG record the July 11 transaction? (4 marks) a. increase Advertising Expense and decrease Prepaid Advertising by $226 each, and also decrease Cash and increase Wages Expense by $75 each b....
-
Exhibit 11 THE MERGER OF HEWLETT-PACKARD AND COMPAQ (A): STRATEGY AND VALUATION Yield Curve for U.S. Treasury Bonds Date 1 mo 3 mo 6 mo 1 yr 2 yr 3 yr 5 yr 7 yr 10 yr 20 yr 30 yr 2/4/2002 1.7 1.77...
Study smarter with the SolutionInn App