Am 30.07.2013 01:34, schrieb Devyn Collier Johnson:
Typing "101 & 010" or "x = (int(101, 2) & int(010, 2))" only gives errors.
What errors? Check out Eric Raymond's essay on asking smart questions,
it's a real eye-opener! ;)
That said, use "0b" as prefix for binary number literals (0b1000 is
On 7/29/2013 7:44 PM, Chris Angelico wrote:
But there's an easier way:
x = 0b101 & 0b010
x
0
I think that might do what you want. Also check out the bin()
function, which will turn an integer into a string of digits.
>>> bin(0b101 | 0b010)
'0b111'
Now you are set to go. Have fun.
--
Terry
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'
--
On 30/07/2013 00:34, Devyn Collier Johnson wrote:
On 07/29/2013 05:53 PM, Grant Edwards wrote:
On 2013-07-29, 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.
http://www.google.co
On Tue, Jul 30, 2013 at 12:48 AM, Devyn Collier Johnson
wrote:
> Now here is something that confuses me, the binary numbers are numbers not
> strings, so why are they put in quotes as if they are strings?
They aren't numbers at that point, they're strings of digits. A number
is represented in var
On 07/29/2013 07:41 PM, Ethan Furman wrote:
On 07/29/2013 04:34 PM, Devyn Collier Johnson wrote:
On 07/29/2013 05:53 PM, Grant Edwards wrote:
On 2013-07-29, Devyn Collier Johnson wrote:
On Python3, how can I perform bitwise operations? For instance, I want
something that will 'and', 'or',
On Tue, Jul 30, 2013 at 12:34 AM, Devyn Collier Johnson
wrote:
>
> I understand the symbols. I want to know how to perform the task in a script
> or terminal. I have searched Google, but I never saw a command. Typing "101
> & 010" or "x = (int(101, 2) & int(010, 2))" only gives errors.
Your probl
On 07/29/2013 04:34 PM, Devyn Collier Johnson wrote:
On 07/29/2013 05:53 PM, Grant Edwards wrote:
On 2013-07-29, 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.
http://www.google
On 07/29/2013 05:53 PM, Grant Edwards wrote:
On 2013-07-29, 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.
http://www.google.com/search?q=python+bitwise+operations
I understand
On 2013-07-29, 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.
http://www.google.com/search?q=python+bitwise+operations
--
Grant Edwards grant.b.edwardsYo
Carl wrote:
> Dear friends,
>
> I am currently porting a fortran program to Python but am stuck on the
> intrinsic IBITS function.
>
> Does anyone know about a replacement function for IBITS in Python?
>
> Yours, Carl
>
> IBITS(I, POS, LEN)
>
> Extracts a sequence of bits.
>
> I
> must b
Incredible, Paul! Thanks a thousand times! /Carl
--
http://mail.python.org/mailman/listinfo/python-list
Carl <[EMAIL PROTECTED]> writes:
> IBITS(I, POS, LEN)
> Extracts a sequence of bits.
> The result has the value of the sequence of LEN bits in I beginning at bit
> POS, right-adjusted and with all other bits zero.
>
> The bits are numbered from 0 to BIT_SIZE(I)-1, from right to left.
>
> Examples
13 matches
Mail list logo