Thread: C operator Question

  1. #1
    Registered User
    Join Date
    Oct 2020
    Posts
    7

    C operator Question

    I may have asked this question some time ago> i tried to check did not find anything so here it goes. How to evaluate this operation:
    PCA0MD &= ~0x40; PCA0MD is a register for a processor.
    I think the &= is a bitwise And and the ~ is a bitwise not ? ...this would be performed on the 0x40 of the operators from left to right?
    Last edited by OutThere; 01-25-2023 at 10:41 AM. Reason: added another thought

  2. #2
    Registered User
    Join Date
    Sep 2022
    Posts
    55
    0x40 is a number with only the 7th bit set like ...0100 0000. The bitwise NOT flips all bits to ... 1011 1111. The bitwise AND removes the 7th bit from PCA0MD like it is set to 0 if it has been 1, or leaves it 0 if it has been 0 before.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. If Else and || operator question
    By Heidegger in forum C Programming
    Replies: 3
    Last Post: 05-13-2011, 03:42 PM
  2. Operator overloading question
    By ranish in forum C++ Programming
    Replies: 2
    Last Post: 04-27-2010, 01:20 PM
  3. Question about :: operator
    By C_Sparky in forum C++ Programming
    Replies: 6
    Last Post: 04-04-2010, 09:54 PM
  4. Question about an operator
    By Programmer_P in forum C++ Programming
    Replies: 6
    Last Post: 05-10-2009, 08:58 PM
  5. new operator question
    By abachler in forum C++ Programming
    Replies: 5
    Last Post: 05-22-2008, 02:06 PM

Tags for this Thread