Search
 
SCRIPT & CODE EXAMPLE
 

C

c bits

// Setting a bit:
number |= 1 << n;

// Clearing a bit
number &= ~(1 << n);

// Toggling a bit
number ^= 1 << n;

// Checking a bit
bit = (number >> n) & 1;

// Changing the nth bit to x
number = (number & ~(1 << n)) | (x << n);
Comment

PREVIOUS NEXT
Code Example
C :: bubble sort 
C :: do...while loop c 
C :: add to beginning of array c 
C :: pointer arithmetic in c 
C :: print to console in c 
C :: multiplication of matrix in c 
C :: casting in c 
C :: calculate median 
C :: maximo comun divisor 
C :: c linked list 
C :: iterate through enum in qt 
C :: do while loop in c 
C :: how to input till end of line in c 
C :: stddef.h 
C :: gitlab ci heroku 
C :: while loop c 
C :: hash function in c 
C :: boolean operators in c 
C :: use frama c online 
C :: c for result 
C :: how to print chicken in c 
C :: print char* address C 
C :: What does x = (a<b)? A:b mean in C programming? 
C :: tytykjtuky 
C :: how to limit tiktok on mikrotik 
C :: My name is c 
C :: switch every right 4 bit with the left 4 bits 
C :: bullseye lxc network problem 
C :: changing data type in one line c program 
C :: Manage Menu Driven Program using switch statement 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =