Skip to content

Instantly share code, notes, and snippets.

Avatar

Cherry Garcia 7PintsOfCherryGarcia

View GitHub Profile
@7PintsOfCherryGarcia
7PintsOfCherryGarcia / getSetbits.c
Last active Jun 20, 2019
print number of set bits
View getSetbits.c
/*
Copied from:
https://giannitedesco.github.io/2019/06/15/abusing-add.html
*/
#include <stdio.h>
int main() {
unsigned int number_bits;
unsigend int number = 255;
@7PintsOfCherryGarcia
7PintsOfCherryGarcia / noIfAdd.c
Last active Jun 18, 2019
Add elements in an array if they are greater or equal to n
View noIfAdd.c
#include <stdio.h>
int main() {
int array[20] = {12,99,14,2,35,67,21,1,12,89,74,32,45,6,78,41,22,54,37,84};
int n = 50;
int sum = 0;
int tmp;
for (int i = 0; i < 20; i++) {
t = (array[i] - n) >> 31;
You can’t perform that action at this time.