t;
> -m.
>
>
> On Thu, 27 Sep 2007 00:14:49 +0200, Ladislav Andel wrote:
>
>
>> Hello,
>> why ~ bit-wise unary operator returns -(x+1) and not bit inversion of
>> the given integer?
>>
>> example:
>> a = 7978
>> a = ~a
>> pyth
In message <[EMAIL PROTECTED]>, Hrvoje Niksic wrote:
> If you want 16-bit unsigned arithmetic, use 2**16 + ~a, which yields
> 57557.
Or why not use "0x ^ a", which returns the same thing.
--
http://mail.python.org/mailman/listinfo/python-list
cau,
maybe int is represented internally as a signed integer
you can use numpy types:
>>> import numpy
>>> ~ numpy.uint16(7978)
57557
-m.
On Thu, 27 Sep 2007 00:14:49 +0200, Ladislav Andel wrote:
> Hello,
> why ~ bit-wise unary operator returns -(x+1) and not bit i
On 2007-09-26, Ladislav Andel <[EMAIL PROTECTED]> wrote:
> Hello,
> why ~ bit-wise unary operator returns -(x+1) and not bit inversion of
> the given integer?
>
> example:
> a = 7978
> a = ~a
> python returns -7979
>
> but I need to get back 57557 as in C
Ladislav Andel <[EMAIL PROTECTED]> writes:
> Hello, why ~ bit-wise unary operator returns -(x+1) and not bit
> inversion of the given integer?
On 2s-complement architectures, -(x+1) *is* bit inversion of the given
integer.
> example:
> a = 7978
> a = ~a
> python returns
On Sep 26, 11:14 pm, Ladislav Andel <[EMAIL PROTECTED]> wrote:
> Hello,
> why ~ bit-wise unary operator returns -(x+1) and not bit inversion of
> the given integer?
>
> example:
> a = 7978
> a = ~a
> python returns -7979
>
> but I need to get back 57557 as
Hello,
why ~ bit-wise unary operator returns -(x+1) and not bit inversion of
the given integer?
example:
a = 7978
a = ~a
python returns -7979
but I need to get back 57557 as in C language.
which is also in binary
000100101010
and inverted
111011010101
Is here any other operator or do