Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Majority Function in C++ using 3 uint8_t

uint8_t a = 0x01; //00000001
uint8_t b = 0xff; //11111111
uint8_t c = 0xf0; //11110000

maj(a,b,c) = 0xf1; //11110001

I'm unsure how to access and compare each bit so I can come to the result?

like image 975
GenericName Avatar asked Oct 20 '25 21:10

GenericName


1 Answers

result = (a & b) | (b & c) | (c & a);
like image 105
Henrik Avatar answered Oct 22 '25 12:10

Henrik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!