Category : bitwise-operators

want to apply OR operation between two numbers, but showing the above error , hence am unable to understand what might be the problem! #include <iostream> using namespace std; int main(){ unsigned char a,b; cin>>a>>b; //input two number cout << a | b; //applying bitwise OR operation } Source: Windows Que..

Read more

While learning about Fenwick Trees, I found this implementation: Source: https://algorithmist.com/wiki/Fenwick_tree class Fenwick_Tree_Sum { vector<int> tree; Fenwick_Tree_Sum(const vector<int>& Arg)//Arg is our array on which we are going to work { tree.resize(Arg.size()); for(int i = 0 ; i<tree.size(); i++) increase(i, Arg[i]); } // Increases value of i-th element by ”delta”. void increase(int i, int delta) { ..

Read more

For my C++ program I want to bit-wise concatenate two 32-bit unsigned integers into one 64-bit unsigned integer. Similar questions have been asked multiple times and the answers mostly looks similar to this: #include <cstdint> #include <iostream> int main() { std::uint32_t leftHalf = 1; std::uint32_t rightHalf = 2; std::uint64_t concatenated = ((std::uint64_t) leftHalf << 32) ..

Read more