Computer Science, asked by avutusindhu9, 3 months ago

There are two integer numbers X and Y, and the value of X and Y is in between 0 to 25. User stores the value under 5 bit number. How many minimum bit is required to store the result of the below expression?Res = 3*(X-Y)​

Answers

Answered by princemathe
1

Answer:

6

Explanation:

?...........................

Answered by akshatdhiman982
12

Answer:

8

Mark me brainliest

Explanation:

To understand the solution we first have to understand why the user chose a 5 bit number. User said numbers lie between 0 to 25 in binary these values will range from 00000 to 11001

Why?

0 in binary is 00000

25 in binary is 11001

Now, it is clear that you need 5 bits to store such a number as the min bits required to store 25 is 5 (as 11001).

Formula for the max number that can be stored per bit is 2X - 1. Where x is the number of bits

The max number that 5 bits can store will be 31 as 11111 = 31.

The range of 3*(X-Y) will be [-75,75]

-75 when X = 0, Y = 25

75 when X = 25, Y = 0

To store 75 in binary we need to calculate the nearest power 2 just greater than 75. Which is 128. Where power of 2 will be 7.

Since the number can also be negative so you need extra binary digital as MSB(Most significant Bit) for negative or positive sign.

So answer is 7 + 1 = 8

Similar questions