ProgrammingVery hard
What is (-8) >> 1 in C if the platform uses arithmetic right shift for signed values?
- A. It is always -4 by the C standard
- B. It is always 2147483644
- C. It is always 0
- D. The result is implementation-defined, so the standard does not fix its value
Correct answer: D. The result is implementation-defined, so the standard does not fix its value
Right shifts of negative signed values are implementation-defined in C. Arithmetic shift gives -4, but the standard does not require it.
More C Programming questions
- To multiply x by 2^k where x is an unsigned 32-bit value, which code is correct?
- A program uses a modulus of 10^9 + 7 and computes (a - b + MOD) % MOD for a and b in [0, MOD). Why add MOD before the %?
- What is the value of 5 & 6 | 3 in C?
- What is the value of 0x80 | 0x01 | 0x10 in decimal?
- What is printed? c #include <stdint.h> #include <stdio.h> int main(void) { uint8t a = 0xB6; uint8t b = (uint8t)(a << 3); uint8t c = a >>…
- Assume uint16t is 16 bits, unsigned int is 32 bits and int is 32 bits. What is printed? c #include <stdint.h> #include <stdio.h> int…