Skip to content

Instantly share code, notes, and snippets.

View 7PintsOfCherryGarcia's full-sized avatar

Julian Regalado Perez 7PintsOfCherryGarcia

View GitHub Profile
@7PintsOfCherryGarcia
7PintsOfCherryGarcia / getSetbits.c
Last active June 20, 2019 13:46
print number of set bits
/*
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 June 18, 2019 14:19
Add elements in an array if they are greater or equal to n
#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;