5. Count Set Bits in Byte Demo - roopakingole/AtmelCodingAssignment GitHub Wiki

####Press Button1 on OLED module to change the state to run this test.

  • This function is implemented using Hamming Weight method to save memory.
  • The same functionality can be implemented efficiently (in processing time) with lookup table method, where the table is pre-populated with number of bits corresponding to its value.
    • const uint8_t lookup_table[256] = {0, 1, 1, 2, 1, .....};
    • num_of_set_bits = lookup_table[data];
  • This function is tested with 5 samples generated randomly using rand()
  • Test result of “Set Bit Count” will be printed on Terminal Window like below:

GOTO Next Page -->6.-N(th)-Bit-Set-Check-Demo

⚠️ **GitHub.com Fallback** ⚠️