newbie seeks insight on bitwise operations..
From: Alan Holloway (alanh_at_kiaro.net)
Date: 07/28/04
- Next message: RoSsIaCrIiLoIA: "Re: strtoint"
- Previous message: Thomas Matthews: "Re: register keyword"
- Next in thread: pete: "Re: newbie seeks insight on bitwise operations.."
- Reply: pete: "Re: newbie seeks insight on bitwise operations.."
- Reply: jacob navia: "Re: newbie seeks insight on bitwise operations.."
- Reply: Tim Hagan: "Re: newbie seeks insight on bitwise operations.."
- Reply: Alex Monjushko: "Re: newbie seeks insight on bitwise operations.."
- Reply: kal: "Re: newbie seeks insight on bitwise operations.."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 28 Jul 2004 08:09:30 -0700
Hi all,
I'm currently learning C (cliche' entry?) and I am finding bitwise
operations a tad challenging. I have a sound understanding of how
boolean logic works (i think), but I find it hard to evaluate the
constructs when I see them in code.
For example, in a network program, a port number is subjected to the
following operation:
port = (port & 0xff) << 8 | port >>8;
AFAIK, port is being assigned the outcome of :
1) An AND operation to ensure that the variable 'port' is not greater
than 255.
2) A left shift by 8 bits (not too sure why though)
3) An OR with the outcome of a right shift by 8 bits (again, not too
sure why).
My apologies for my obvious lack of clue, but i'd really appreciate
some help here in understanding,
as this has been a bit of a show stopper for sometime, and i've
finally realised i'm probably not going to crack this on my own :)
Thanks all
Al.
- Next message: RoSsIaCrIiLoIA: "Re: strtoint"
- Previous message: Thomas Matthews: "Re: register keyword"
- Next in thread: pete: "Re: newbie seeks insight on bitwise operations.."
- Reply: pete: "Re: newbie seeks insight on bitwise operations.."
- Reply: jacob navia: "Re: newbie seeks insight on bitwise operations.."
- Reply: Tim Hagan: "Re: newbie seeks insight on bitwise operations.."
- Reply: Alex Monjushko: "Re: newbie seeks insight on bitwise operations.."
- Reply: kal: "Re: newbie seeks insight on bitwise operations.."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|