Bit Manipulation

Specify a certain bit 1
x |= (1 << y);
Specify a certain bit 0
x &= ~(1 << y);
Specify the reverse of a certain bit
x ^= (1 << y);
Get the value from a certain bit
((x >> y) & 1);
Search for a command to run...

x |= (1 << y);
x &= ~(1 << y);
x ^= (1 << y);
((x >> y) & 1);
No comments yet. Be the first to comment.
Introduce There are two ways to implement thread according to official documentation and the first one is recommended How to quit a thread correctly Inherit QObject workerThread.quit(); workerThread.wait(); Inherit QThread Thread::Thread() ...

Thinking If we want to achieve this effect, we need to understand the mathematical model. When we zoom in, the object won't change its size. Actually, It's our camera getting closer to the object. In other words, what we can see becomes smaller. Defa...

Let's look at matrix multiplication first vtkNew<vtkTransform> transformA; transformA->Translate(10, 0, 0); std::cout<<"matrixA="<<std::endl<<*transformA->GetMatrix()<<std::endl; vtkNew<vtkTransform> transformB; transformB->RotateZ(90); std::cout<<"...

Method 1(index-based iteration) std::vector<int> v = { 1, 2, 3, 4, 5}; for (size_t i = 0; i < v.size(); ++i) { std::cout << v[i]; } Method 2(range-for loop) std::vector<int> v = { 1, 2, 3, 4, 5}; for (const int& i : v) // Access by const referen...

Preface There are two forms of enumeration in C++, enum and enum class. Enum is the pre-c++11 syntax, which means it is an unscoped enumeration. The enum class was introduced in C++11 and provides a scoped enumeration Unscoped enumerations // A.h enu...
