Algorithms_in_C++ 1.0.0
Set of algorithms implemented in C++.
|
[Next higher number with same number of set bits] (https://www.geeksforgeeks.org/next-higher-number-with-same-number-of-set-bits/) implementation More...
#include <cassert>
#include <iostream>
Namespaces | |
namespace | bit_manipulation |
for IO operations | |
Functions | |
uint64_t | bit_manipulation::next_higher_number (uint64_t x) |
The main function implements checking the next number. | |
static void | test () |
Self-test implementations. | |
int | main () |
Main function. | |
[Next higher number with same number of set bits] (https://www.geeksforgeeks.org/next-higher-number-with-same-number-of-set-bits/) implementation
Given a number x, find next number with same number of 1 bits in it’s binary representation. For example, consider x = 12, whose binary representation is 1100 (excluding leading zeros on 32 bit machine). It contains two logic 1 bits. The next higher number with two logic 1 bits is 17 (100012).
A binary number consists of two digits. They are 0 & 1. Digit 1 is known as set bit in computer terms.
int main | ( | void | ) |
|
static |
Self-test implementations.