Re: Bitwise Operations

Discussion in 'Python' started by Peter Otten, Jul 30, 2013.

  1. Peter Otten

    Peter Otten Guest

    Devyn Collier Johnson wrote:

    > On Python3, how can I perform bitwise operations? For instance, I want
    > something that will 'and', 'or', and 'xor' a binary integer.


    >>> 0b1010 | 0b1100

    14
    >>> bin(_)

    '0b1110'
    >>> 0b1010 & 0b1100

    8
    >>> bin(_)

    '0b1000'
    >>> 0b1010 ^ 0b1100

    6
    >>> bin(_)

    '0b110'
     
    Peter Otten, Jul 30, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Sm9u?=

    BitWise Operations

    =?Utf-8?B?Sm9u?=, Jan 23, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    3,383
    =?Utf-8?B?Sm9u?=
    Jan 24, 2006
  2. E. Robert Tisdale

    Re: seeking bitwise operations solution

    E. Robert Tisdale, Aug 17, 2003, in forum: C Programming
    Replies:
    4
    Views:
    458
  3. Carl
    Replies:
    3
    Views:
    4,113
    John Machin
    Aug 19, 2005
  4. Chris
    Replies:
    6
    Views:
    2,482
    Daniel Pitts
    Jan 5, 2007
  5. Alan Holloway

    newbie seeks insight on bitwise operations..

    Alan Holloway, Jul 28, 2004, in forum: C Programming
    Replies:
    11
    Views:
    444
    Keith Thompson
    Jul 30, 2004
Loading...

Share This Page