we can shift using >> operator, and we can use ‘/’ to divide in java. What I am asking is what really happens behind the scene when we do these operations, both are exactly same or not..?
Share
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, absolutely not the same.
You can use
>>to divide, yes, but just by 2, because>>shift all the bits to the right with the consequence of dividing by 2 the number.This is just because of how binary base operations work. And works for unsigned numbers, for signed ones it depends on which codification are you using and what kind of shift it is.
eg.