Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[Moved] can i have a c code for single bit flipping algorithm

Status
Not open for further replies.

Seetharavip

Newbie level 1
Joined
May 9, 2016
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
5
can someone
provide
c code for single bit flipping algorithm

[...email address deleted]
 
Last edited by a moderator:

Re: can i have a c code for single bit flipping algorithm

i think there are several examples of this online. You also might want to check compiler vendor info to see if a specific style is preferred. For example, x |= (1<<idx) will set a bit "idx" in x. A compiler might be able to do this with multiple instruction or a single specialized instruction on some platforms.

but overall, it is:
x |= (1<<idx); // set
x &= ~(1<<idx); //clear
x ^= (1<<idx); // toggle.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top