1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
alexdok [17]
3 years ago
15

2. Assuming that the bits in an integer are numbered from 0, from right (least significant) to left (most significant), write an

expression using bitwise logical operators to extract the 4 bits numbered 6 to 3 from an integer i1, and shift them all down so that bit numbered 3 ends up in position number 1.
Computers and Technology
1 answer:
3241004551 [841]3 years ago
4 0

Answer:

Explanation:

Two ways of interpreting this question

(I) Shifting all the bits along with the choosen four,

in that case it will be i1>>2;

(ii) Just shifting the choosen four bits and keeping the remaining as it is.

It is equivalent to replacing the first four bits of i1 with i1>>2. let us call N = i1, and M = i1>>2.

max = ~0 //All one's

//1's through position 4, then all zeros

left = max - ((1<<4) - 1);

So we just have zeros between bits one to four and other are one.

Now final step;

(N&left) | m

You might be interested in
Write, compile and test (show your test runs!) program that calculates and returns the fourth root of the number 81, which is 3.
lys-0071 [83]

Answer:

I am writing a JAVA program. Let me know if you want the program in some other programming language.

public class FourthRoot{ //class to calculate fourth root of 81

public static void main(String[] args) { //start of main() function body

   double square_root; //declares to hold the fourth root of 81

   double number=81; // number is assigned the value 81

/* calculates the fourth root of number using sqrt() method twice which means sqrt() of sqrt(). This is equivalent to pow(number,(0.25)) where pow is power function that computes the fourth root by raising the number 81 to the power of 0.25 which is 1/4 */

   square_root=Math.sqrt(Math.sqrt(number));

//displays the fourth root of 81 i.e. 3

     System.out.println("Fourth Root of 81 is "+ square_root); } }

Explanation:

The program is well explained in the comments given along with each statement of the program . Since it was the requirement of the program to user Math.sqrt() method so the fourth root of number= 81 is computed by taking the sqrt() of 81 twice which results in the fourth root of 81 which is 3.

So the first sqrt(81) is 9 and then the sqrt() of the result is taken again to get the fourth root of 81. So sqrt(9) gives 3. So the result of these two computations is stored in square_root variable and the last print statement displays this value of square_root i.e. the fourth root of number=81 which is 3.

Another way to implement the program is to first take sqrt(81) and store the result in a variable i.e. square_root. After this, again take the sqrt() of the result previously computed and display the final result.

public class FourthRoot{

   public static void main(String[] args) {

   double square_root;

   double number=81;

   square_root=Math.sqrt(number);

  System.out.println("Fourth Root of 81 is: "+ Math.sqrt(square_root)); } }

The program along with its output is attached in a screenshot.

5 0
4 years ago
Explain: The fetch part of fetch decode execute cycle
MArishka [77]

Answer:

Look at the image

Explanation:

7 0
3 years ago
What is the answer ??​
Anna11 [10]

Answer:

option 1 is correct go with 1s .

3 0
3 years ago
Is the ability to choose the start and finish times, but they must complete a full day’s work
Hatshy [7]
Yes ma’am , can of spam. what she said up there ^*
4 0
3 years ago
Which of the statements below explains why a budget is useful
Papessa [141]

The answer is D. All the other answers describe what a budget CAN be like, not necessarily what it is for everyone, if that makes sense.

8 0
3 years ago
Other questions:
  • Type of media that uses laser technology to store data and programs is
    6·1 answer
  • Which of the following statements about arrays are true?
    10·1 answer
  • Encapsulate the following Python code from Section 7.5 in a function called my_sqrt that takes a as a parameter, chooses a start
    7·1 answer
  • List the five body functions that monitor homeostasis.
    7·1 answer
  • Given a string variable s that has already been declared, write some code that repeatedly reads a value from standard input into
    12·1 answer
  • Por favor definir que es un pseudocódigo y que es un diagrama de flujo.
    13·2 answers
  • What improved image quality in televisions?
    5·1 answer
  • Which is an advantage of using a flat file instead of a relational database?
    5·1 answer
  • Please help.........​
    13·1 answer
  • It is the responsibility of a manager to understand the company’s IT architecture and corresponding infrastructure so that the
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!