[Tutor] How to convert a decimal integer into binary

wesley chun wescpy at gmail.com
Wed Sep 20 19:39:59 CEST 2006


> I came across some code, which uses bit operator. I could not understand how
> the logic of that code. If anyone knows to convert the decimal into binary
> using BIT OPERATOR, then please help me.


please reply to the list, not just me.

since this is your homework assignment, i cannot give you the answer,
but i will tell you that there are six bit operators (not one):

- << left shift
- >> right shirt
- & bitwise AND
- | bitwise OR
- ^ bitwise XOR (eXclusive OR)
- ~ bit inversion

your solution will likely include (at least) one of the shifters and
(at least) one of the bitwise operators.

good luck!
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2007,2001
    http://corepython.com

wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com


More information about the Tutor mailing list