Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Bitwise operators

Bitwise operators

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    Waldermort
    wrote on last edited by
    #1

    I still didn't get the hang of these. We can add a value like so: uRetVal |= DV_CENTERALL; But I want to remove a value also if it is present: uRetVal ^= (uRetVal | DV_RIGHT) == uRetVal ? DV_RIGHT : 0; Is the above correct, or is there an easier better way to do it?

    C R 2 Replies Last reply
    0
    • W Waldermort

      I still didn't get the hang of these. We can add a value like so: uRetVal |= DV_CENTERALL; But I want to remove a value also if it is present: uRetVal ^= (uRetVal | DV_RIGHT) == uRetVal ? DV_RIGHT : 0; Is the above correct, or is there an easier better way to do it?

      C Offline
      C Offline
      cje
      wrote on last edited by
      #2

      to remove DV_CENTERALL how about uRetVal = uRetVal & ~DV_CENTERALL

      cje

      W 1 Reply Last reply
      0
      • C cje

        to remove DV_CENTERALL how about uRetVal = uRetVal & ~DV_CENTERALL

        cje

        W Offline
        W Offline
        Waldermort
        wrote on last edited by
        #3

        Thanks for that. The '~' operator is not on MSDN, it's in the index, but the page has a large "Empty Index Entry" written across the top. So I am guessing it is the NOT operator?

        C 1 Reply Last reply
        0
        • W Waldermort

          Thanks for that. The '~' operator is not on MSDN, it's in the index, but the page has a large "Empty Index Entry" written across the top. So I am guessing it is the NOT operator?

          C Offline
          C Offline
          cje
          wrote on last edited by
          #4

          yes, the ~ operator is the Bitwise NOT

          cje

          1 Reply Last reply
          0
          • W Waldermort

            I still didn't get the hang of these. We can add a value like so: uRetVal |= DV_CENTERALL; But I want to remove a value also if it is present: uRetVal ^= (uRetVal | DV_RIGHT) == uRetVal ? DV_RIGHT : 0; Is the above correct, or is there an easier better way to do it?

            R Offline
            R Offline
            Rage
            wrote on last edited by
            #5

            http://www.codeproject.com/useritems/Binary_Guide.asp[^]

            ~RaGE();

            I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups