For class I need to write a program that inputs a file (the dividend), performs binary division on the file (using 0x12 as the divisor), and outputs the remainder(checksum).
I have researched binary division algorithms and I get the general gist, but I'm still unsure where to start. How would I store the dividend and divisor? As two arrays of bits?
Then, I need to figure out how to perform shifts and XORs on the the binary numbers.
Maybe I should use bitwise operations?
I don't think you need to work with bits for this. 0x12 is equivalent to the decimal 18, so x/0x12 is the same as x/18.
All of the fundamental data types are stored as bytes and bytes are made of bits (or words), so one standard of an array of bits is a word (four bits, I think). Or, you can use char; I believe the C++ standard guarantees that char will always be 8 bits.
Actually, the way I understand it, we are using polynomial binary division--which is different. So, the binary numbers can not be converted to decimal.
Well, for more than 8 bits, you can store the coefficients of the dividend and divisor in std::vector<bool> or std::bitset<N>.
In your case, std::bitset might work better because you can use bitwise operations on the entire container, e.g.