Count Ones

binary_counts_with_fingersHere is a simple task. Given an array of 10,000 random unsigned short integers (16-bit values) count the number of bits set to one (1). In the following example we have an array of two (2) unsigned shorts:

41344 1010000110000000

58520 1110010010011000

The first number 41,344 contains 4 ones and the second value 58,520 contains 7 ones for a total of (4 + 7) = 11 ones. Continue reading “Count Ones”