Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #45800

Re: help in obtaining binary equivalent of a decimal number in python

References <7f794f03-03c9-44de-8312-4ad33b68c266@googlegroups.com>
Date 2013-05-23 21:37 +1000
Subject Re: help in obtaining binary equivalent of a decimal number in python
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.2012.1369309056.3114.python-list@python.org> (permalink)

Show all headers | View raw


On Thu, May 23, 2013 at 9:30 PM,  <lokeshkoppaka@gmail.com> wrote:
> i need to get 32 bit binary equivalent of a decimal and need to change the 0's to 1's and 1's to 0's
> For Example
> if the input is 2
> Output should be:
> the 32bit equivalent of 2 :0000 0000 0000 0000 0000 0000 0000 0010
> and the 1's compliment is:1111 1111 1111 1111 1111 1111 1111 1101
>
>
>
> is there any pre-defined function to get the above results in python??

You're asking for bitwise negation. Now that you know the keyword(s)
to look for, you should be able to figure out the rest with a few
quick docs and/or web searches.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

help in obtaining binary equivalent of a decimal number in python lokeshkoppaka@gmail.com - 2013-05-23 04:30 -0700
  Re: help in obtaining binary equivalent of a decimal number in python Chris Angelico <rosuav@gmail.com> - 2013-05-23 21:37 +1000
  Re: help in obtaining binary equivalent of a decimal number in python Dave Angel <davea@davea.name> - 2013-05-23 07:55 -0400

csiph-web