Results 1 to 3 of 3

Thread: Setting desired bit in a 32 bit number

  1. #1
    Expert Member
    Join Date
    Oct 2006
    Answers
    209

    Setting desired bit in a 32 bit number

    Hi guys, how to set a particular desired bit in a 32 bit number...function should be of format... psedofunct (bit number to set or reset, number to operate on)

    NOTE : This question was asked by pratap, I am posting it in proper forum]


  2. #2
    Junior Member
    Join Date
    Jan 2007
    Answers
    9

    Re: Setting desired bit in a 32 bit number

    guess you can use this macro.
    #define SETBIT(bitnumber,number) (number)|(1<<(bitnumber-1))


  3. #3
    Junior Member
    Join Date
    Jan 2007
    Answers
    9

    Re: Setting desired bit in a 32 bit number

    guess you can use these macros.
    #define SETBIT(bitnumber,number) (number)|(1<<(bitnumber-1))
    #define RESETBIT(bitnumber,number) (number)&(~(1<<(bitnumber-1)))
    Hopefully this helps.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact