Search
 
SCRIPT & CODE EXAMPLE
 

CPP

how to find the left most bit 1 in binary of any number

//C++ Code to find the value of 2^n = highestOneBit(). 
int highestOneBit(int i) {
    i |= (i >>  1);
    i |= (i >>  2);
    i |= (i >>  4);
    i |= (i >>  8);
    i |= (i >> 16);
    return i - (i >> 1);
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: Diamond pattren program in C++ 
Cpp :: c++ Unable to get CMake Tutorial example to compile 
Cpp :: default argument c++ 
Cpp :: displaying m images m windows opencv c++ 
Cpp :: how to change the default camera speed values opengl 
Cpp :: access the element of vector point2f c++ 
Cpp :: Tricky Subset Problem 
Cpp :: cpp cout more than 1 value 
Cpp :: Write C++ program that will ask to choose from three cases. 
Cpp :: c++ read_ascii 
Cpp :: xor in c++ 
Cpp :: different way to print string in c++ 
Cpp :: cpp reference array 
Cpp :: deal with bad input cpp 
Cpp :: how to convert malloc function to cpp 
Cpp :: ex:Roblox 
Cpp :: how to complie c++ to spesific name using terminal 
Cpp :: vector übergeben c++ 
Cpp :: Normal Initialisation of 3D Vector 
Cpp :: how to use printf with microseconds c++ 
Cpp :: Swift if...else Statement 
Cpp :: tic tac toe in cpp 
Cpp :: error when using template base class members 
Cpp :: declare a structer in cpp 
Cpp :: Casino Number Guessing Game - C++ 
Cpp :: how to code a segment tree in c++ 
Cpp :: array list cpp 
Cpp :: pre increment vs post increment c++ 
Cpp :: Dfs program in c++ 
C :: calculate distance between 2 points X Y axis 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =