Question DSA-BIT-0077
HardWhy can left-shifting a signed int in C be undefined behaviour?
- A.
Only right shifts are defined
- B.
Because of endianness
- C.
Sign up free to see the answer and a step-by-step explanation.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Bit Manipulation question
Why can left-shifting a signed int in C be undefined behaviour?
Only right shifts are defined
Because of endianness
Sign up free to see the answer and a step-by-step explanation.
Shifting a 1 into or past the sign bit (or shifting negatives) overflows
Shifts are always undefined