473,387 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

invert or not ?

hello,

from the manual I read that a bitwise inversion should be done by invert.
But from some experiments I see that not works equally well.
Is this coincidence ?

(The disadvantage of invert is that I've to import operators)

thanks,
Stef
Mar 1 '08 #1
2 1776
Stef Mientki wrote:
from the manual I read that a bitwise inversion should be done by invert.
But from some experiments I see that not works equally well.
Is this coincidence ?
[Are cryptical posts contagious? I hope not.]

Please explain what you did in your experiments and what did not work as
expected.
(The disadvantage of invert is that I've to import operators)
Do you travel with a suitcase or a lorry? The advantage of import is that
your programs won't grind to a halt loading stuff you don't need most of
the time. By the way
>>operator.invert(42) == ~42
True

Peter
Mar 1 '08 #2
On 2008-03-01, Stef Mientki <st**********@gmail.comwrote:
from the manual I read that a bitwise inversion should be done
by invert. But from some experiments I see that not works
equally well.
What experiments are those?
>>print ~0xaa, not 0xaa
-171 False
>>print ~0x55, not 0x55
-86 False
>>>
print ~True, not True
-2 False
>>>
Is this coincidence ?
Is what coincidence?
(The disadvantage of invert is that I've to import operators)
No you don't.

--
Grant Edwards grante Yow! If elected, Zippy
at pledges to each and every
visi.com American a 55-year-old
houseboy...
Mar 2 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Des Small | last post by:
Lately I have found myself using a pattern to make new dictionaries quite often, by which I mean twice: def invert(d): nd = {} ).append(key) for k, v in d] return nd def count(l): d = {}
5
by: Me Padre | last post by:
Hoping someone can help with this. I know I can do this programatically using a loop but I thought there might be some easier or more effective way. I am trying to invert an array. i.e. ...
3
by: Peter Aitken | last post by:
I want to invert all the bits (all 0s to 1s, all 1s to 0s) in a type ushort. I though I would use the complement operator ~ but the compiler won't buy it. How can I do this? Thanks, --...
4
by: Derek Martin | last post by:
Hi List, I have an arraylist of objects. I have created my own IComparable in the object to return the sort on datetime. This works great! Now, I'd like to invert the sort. Currently, it gives...
10
by: rtilley | last post by:
s = list('some_random_string') print s s.reverse() print s s = ''.join(s) print s Surely there's a better way to do this, right?
41
by: rick | last post by:
Why can't Python have a reverse() function/method like Ruby? Python: x = 'a_string' # Reverse the string print x Ruby: x = 'a_string' # Reverse the string
2
by: billelev | last post by:
In other languages it's possible to prefix a boolean with a "!" to invert it, however this doesn't seem to work in VBA. Is there an alternative in VBA? I'd like the flexibility to do something...
1
by: mahesh.nimbalkar | last post by:
Hi, I have color as System.Drawing.Color c1 object as background color. Now I would like to get another System.Drawing.Color c2 object which is invert of c1 color to be used as foreground...
0
by: Karthik | last post by:
Hi, I want to record a sound wave from a mic and at the same time invert it and play the inverted wave.My code goes as follows, however nothing is written into the E:\inverted.wav file.Thanks in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.