A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://TheAlgorithms.github.io/C-Plus-Plus/d4/d48/hamming__distance_8cpp_source.html below:

TheAlgorithms/C++: bit_manipulation/hamming_distance.cpp Source File

Go to the documentation of this file. 37 while

(value) {

// until all bits are zero 38 if

(value & 1) {

// check lower bit 41

value >>= 1;

// shift bits, removing lower bit 61

assert(a.size() == b.size());

64 for

(

size_t

i = 0; i < n; i++) {

65

count += (b[i] != a[i]);

69

}

// namespace hamming_distance 70

}

// namespace bit_manipulation 101 test

();

// execute the tests 102

uint64_t a = 11;

// 1011 in binary 103

uint64_t b = 2;

// 0010 in binary 105

std::cout <<

"Hamming distance between "

<< a <<

" and "

<< b <<

" is "

uint64_t bitCount(uint64_t value)

static void test()

Function to the test hamming distance.

uint64_t hamming_distance(uint64_t a, uint64_t b)

int main()

Main function.

Functions for Hamming distance implementation.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4