top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

When x>>1 and x/2 gives different result in C/C++?

+3 votes
52 views
When x>>1 and x/2 gives different result in C/C++?
posted Dec 18, 2015 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote

For positive integers x>>1 and x/2 would be same but for negative its not see the example

x=5
x>>1 is 2
x/2 is also 2

if
x=-5
x/2 is -2
but x>>1 is -3

answer Dec 19, 2015 by Salil Agrawal
0 votes

Answer will be same on positive numbers means(dividing the number by 2).But on negative number it will be not same.

answer Dec 20, 2015 by Rajan Paswan
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...