Skip to content

Latest commit

 

History

History
30 lines (21 loc) · 1.32 KB

File metadata and controls

30 lines (21 loc) · 1.32 KB

Bit manipulation

Bit manipulation is the act of manipulating bits to detect errors (hamming code), encrypts and decrypts messages (more on that in the 'ciphers' folder) or just do anything at the lowest level of your computer.

Example

Below is a simple example using the get_set_bits_count_using_brian_kernighans_algorithm function from bit_manipulation/count_number_of_one_bits.py.

from bit_manipulation.count_number_of_one_bits import get_set_bits_count_using_brian_kernighans_algorithm

print(get_set_bits_count_using_brian_kernighans_algorithm(25))  # 3
print(get_set_bits_count_using_brian_kernighans_algorithm(58))  # 4

This repository also includes doctest examples in the implementation that can be run with:

python3 bit_manipulation/count_number_of_one_bits.py