0 0 votes What is the output? Programming in C programming-in-c output + – Parshu gate 1.2k views answer comment Share Follow Print 0 reply Please log in or register to add a comment.
1 1 vote as -1 will be represented as 2's complement form therefore -1 = 1111 1111 in 2's complement (assuming 8 bit representation) hence -1<<1 will shift above binary bits left by 1 i.e -1<<1 = 1111 1110 therefore result will be "fe" in hexadecimal or you may also get fffe for 16 bit representation or ffff fffe for 32 bit representation but hexadecimal value of last 4 least significant bits will always be 'e' and remaining preceding value will be 'f' Niraj Singh 2 answered Sep 26, 2017 Niraj Singh 2 comment Share Follow See all 5 Comments 5 5 Comments reply Show 2 previous comments saipriyab commented Sep 26, 2017 i edited by saipriyab Sep 26, 2017 reply Follow flag Negative number can be represented in three ways 1.signed Integer 2.1's complement 3.2's complement So -1 can be represented as 1000 0001 so 2'scomplement should be 01111111 and left shift we will get 11111110 0 0 replyShare Niraj Singh 2 commented Sep 26, 2017 reply Follow flag @ARJUN SIR , yes sir , thank you for your valuable comment 0 0 replyShare arch commented Nov 14, 2017 reply Follow flag https://stackoverflow.com/questions/13544519/bitwise-shift-operators-on-signed-types it says behaviour is undefined 1 1 replyShare Please log in or register to add a comment.