<< is bitwise left shift operator.
The result of the _expression_ a << b
is a value that the value a is shifted right by b positions (bits).
(b number of bits removed from the left and b number of 0 bits added from right)
the value b should be less than the number of total bits  of a
 
 
>> is bitwise right shift operator.
The result of the _expression_ a >> b
is a value that the value a is shifted left by b positions (bits).
(b number of bits removed from the right and b number of 0 bits added from left (if a is unsigned or if a is a signed value greater than 0)
the value b should be less than the number of total bits  of a
suppose that the integer 5 is represented as follows
 
0000 0000 0000 0101
 
5 >> 1 will be the value
 
0000 0000 0000 0010  (2)
 
5 >> 2 will be the value
 
0000 0000 0000 0001  (1)
 
5 << 1 will be the value
 
0000 0000 0000 1010  (10)
 
5 << 2 will be the value
 
0000 0000 0001 0100  (20)
 
in your main function, you call the function printf to write the value of integer expressions to stdout in decimal system,
I mean the expresions x, x << 2 and x >> 2.
 
nerg
 
 
 
----- Original Message -----
Sent: Thursday, December 16, 2004 3:50 PM
Subject: (PT) Digest Number

hello sir/mam,

can anyone can explain me how this program is solved manually and in compiler....

main()

{

int x=5;

printf("%d %d %d ",x,x<<2,x>>2);

}

The answer for this is  5,1,20... but how the answer is approached...

can anyone helpme.....

reply in [EMAIL PROTECTED]

 

thz,

with warm wishes bye,

suresh

 

 

 


Do you Yahoo!?
Jazz up your holiday email with celebrity designs. Learn more.

To unsubscribe : [EMAIL PROTECTED]






To unsubscribe : [EMAIL PROTECTED]




Yahoo! Groups Sponsor
ADVERTISEMENT
click here
Web Bug from http://us.adserver.yahoo.com/l?M=295196.4901138.6071305.3001176/D=groups/S=:HM/A=2128215/rand=635650508


Yahoo! Groups Links

Reply via email to