In C, on a 32-bit machine, I was just wondering if 1>>31 returns -1 given 1 is a signed integer, since for 2’s-complement, while doing right shift (arithmetic), sign bit is copied giving the result
1111 1111 1111 1111 1111 1111 1111 1111
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, the result will be zero in any conforming implementation.
C99, 6.5.7/5 (“Bitwise shift operators”) states:
Since
1is nonnegative, the result is the integral quotient of1 / (2^31)which is obviously zero.