C/C++ Bit Array or Bit Vector

I think you’ve got yourself confused between arrays and numbers, specifically what it means to manipulate binary numbers. I’ll go about this by example. Say you have a number of error messages and you want to return them in a return value from a function. Now, you might label your errors 1,2,3,4… which makes sense … Read more

Java Iterate Bits in Byte Array

You’d have to write your own implementation of Iterable<Boolean> which took an array of bytes, and then created Iterator<Boolean> values which remembered the current index into the byte array and the current index within the current byte. Then a utility method like this would come in handy: private static Boolean isBitSet(byte b, int bit) { … Read more

Is a byte always 8 bits?

Yes, a byte is always 8 bits in modern computing. The book uses Words, not bytes In the book, the word and the size of the word is explicitly mentioned, while there is not a word (haha) about bytes. Look at the phrase ..is represented in RAM by 32 consecutive 16-bit words.. The whole size … Read more