
January 6th, 2003, 05:40 AM
|
|
Junior Member
|
|
Join Date: Apr 2002
Location: Hyderabad
Posts: 17
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Right Shifting
Hai All,
Here is a some code i executed , its giving some what strange values , right shift means dividing the value by 2 . On this basis i have excuted the code.
The code follows
#include <stdio.h>
int main()
{
char ch = -0x7f ;
int i = ch;
printf("%d %d %d %d\n",ch,ch>>1,-127/2,i/2);
}
Out put is :
-127 -64 -63 -63
Here -127/2 and i/2 are giving -63 as a result
But ch>>1 is giving -64 as a result . How it is possible ?
Please explain me.
Suri
|