i want to reverse the bits of unsigned number by using bitwise operatores ( & , | , ^ , ~ , << , >> ) , i am working in borland C++
example :
00110101 -> 10101100
please help me if u can .....
![]()
This is a discussion on who can help me ???!!!! within the C++ Programming forums, part of the General Programming Boards category; i want to reverse the bits of unsigned number by using bitwise operatores ( & , | , ^ , ...
i want to reverse the bits of unsigned number by using bitwise operatores ( & , | , ^ , ~ , << , >> ) , i am working in borland C++
example :
00110101 -> 10101100
please help me if u can .....
![]()
What have you tried so far?
C + C++ Compiler: MinGW port of GCC
Version Control System: Bazaar
Look up a C++ Reference and learn How To Ask Questions The Smart Way
?????
thanks citizen ,,,
but i must use ^ with what ????
what have you tried so far?
Originally Posted by brewbuck:
Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.
xor doesn't help much for reversing. it's better used for inverting.Originally Posted by backtolife
Kurt
http://www.jjj.de/fxt/fxtbook.pdf
Have a look at the bit wizardry chapter.
silk.odyssey
Announcement: HomeworkOriginally Posted by backtolife
Post the code of your initial attempt and better help will follow.
[edit]Or cheat by searching for "reverse bits".
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
I would use &, |, << and >>, or perhaps their assignment variants.Use exclusive or.
C + C++ Compiler: MinGW port of GCC
Version Control System: Bazaar
Look up a C++ Reference and learn How To Ask Questions The Smart Way
> please help me if u can .....
Start by showing us a program which uses & and >> in a for loop to print each bit in turn.
If you then use << on that bit, you might be onto something.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I support http://www.ukip.org/ as the first necessary step to a free Europe.