Find the signed binary expansion of the number -6.
To convert a negative number into its signed binary representation using two’s complement:
10110
11010
11100
10101
Step 1: Understanding Signed Binary Representation
In signed binary representation, negative numbers are represented in two’s complement form.
The two’s complement representation uses the most significant bit (MSB) to indicate the sign of the number, where ‘0’ represents positive and ‘1’ represents negative numbers.
Step 2: Find Binary Expansion for 6
The binary representation of +6 is 0110 in 4-bit binary.
Step 3: Apply Two’s Complement to Get -6
To convert 6 to -6, we perform the following steps:
0110 → 10011001 + 1 = 1010Thus, the two’s complement representation of -6 in 4-bit is 1010.Step 4: Extending to 5 Bits for Signed Expansion
To extend this to 5 bits, we need to add an additional '1' at the left for the negative sign, resulting in 11010.
Thus, the correct answer is (B).
Consider the following code:
main() {
int x = 126, y = 105;
{
if (x > y)
x = x - y;
else
y = y - x;
}
while (x != y)
printf("%d", x);
}
Consider the following code:
int a;
int arr[] = {30, 50, 10};
int *ptr = arr[10] + 1;
a = *ptr;
(*ptr)++;
ptr = ptr + 1;
printf("%d", a + arr[1] + *ptr);
Consider the following code:
int a;
int arr[] = {30, 50, 10};
int *ptr = arr[10] + 1;
a = *ptr;
(*ptr)++;
ptr = ptr + 1;
printf("%d", a + arr[1] + *ptr);
Consider the following hierarchical cache system with the following access times:
\[ \begin{array}{|c|c|c|} \hline \textbf{Cache Level} & \textbf{Hit Rate} & \textbf{Access Time} \\ \hline L1 & 90\% & 1 \text{ ns} \\ L2 & 80\% & 10 \text{ ns} \\ L3 & 100\% & 100 \text{ ns} \\ \hline \end{array} \]Find \( T_{avg} \) for hierarchical or simultaneous access.
What is the output of the following C code?
void foo(int *p, int x) {
*p = x;
}
void main() {
int *z;
int a = 20, b = 25;
z = a; // Incorrect: Should be z = a;
foo(z, b);
printf("%d", a);
}
Issue: The statement z = a; is invalid because a is an integer, and z is a pointer.