who can help me ???!!!!

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 ( & , | , ^ , ...

  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    8

    who can help me ???!!!!

    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 .....


  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,718
    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

  3. #3
    Registered User
    Join Date
    Jun 2006
    Posts
    8
    ?????

  4. #4
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,700
    Use exclusive or.

  5. #5
    Registered User
    Join Date
    Jun 2006
    Posts
    8
    thanks citizen ,,,

    but i must use ^ with what ????

  6. #6
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,465
    what have you tried so far?
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    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.

  7. #7
    ZuK
    ZuK is offline
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    Quote Originally Posted by backtolife
    thanks citizen ,,,

    but i must use ^ with what ????
    xor doesn't help much for reversing. it's better used for inverting.
    Kurt

  8. #8
    Registered User
    Join Date
    Dec 2003
    Posts
    167
    http://www.jjj.de/fxt/fxtbook.pdf

    Have a look at the bit wizardry chapter.
    silk.odyssey

  9. #9
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Quote Originally Posted by backtolife
    please help me if u can .....
    Announcement: Homework

    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.*

  10. #10
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,718
    Use exclusive or.
    I would use &, |, << and >>, or perhaps their assignment variants.
    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

  11. #11
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,537
    > 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.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21