Category : binary

I’m working with bits and I don’t understand this operator. unsigned int number = 6; number = (number>>1)&1; The resulting value in number is 1 and I don’t know why. 6 is 0110 in binary. If I shift 1 position to the right the result is 0011, which is 3. The value in number now ..

Read more

I have an assignment to build a 7 segment BCD counter. The idea is to generate binary numbers 000, 001, etc all the way up to 9, and then feed them into a BCD decoder and the display will be a 7 segment display that counts 0, 1, 2, 3, 4, 5, 6, 7, 8, ..

Read more

I’m solving a c++ problem that requires updating a binary file. Examples shows binary file is opened with ios::in ios::out ios::binary flags. I tried the following code but the binary file won’t update on windows OS. #include <fstream> #include <iostream> using namespace std; void printFileContent() { ifstream inFile ("test.bin", ios::in | ios::binary); if (inFile) { ..

Read more