Reading specific bit values from a file.
-
How can I read a specific bit or series of bits (as a bit array) from a file. I can use a file stream and binary reader to get specific bytes but I do not know how to easily convert this into a bit array (at least not very efficiently). Jim
-
How can I read a specific bit or series of bits (as a bit array) from a file. I can use a file stream and binary reader to get specific bytes but I do not know how to easily convert this into a bit array (at least not very efficiently). Jim
To turn a byte into bits, bool is the most obvious choice ( the only one I can think of with 2 states ) and you & the value with 0x1, 0x2, 0x4, 0x8, ox10, etc to strip the bits. I reckon this is what you've thought of, but I don't know of any more efficient way, excepting that I'd be more inclined to do this when I need the value, and not store it as bits in memory. Christian Graus - Microsoft MVP - C++
-
To turn a byte into bits, bool is the most obvious choice ( the only one I can think of with 2 states ) and you & the value with 0x1, 0x2, 0x4, 0x8, ox10, etc to strip the bits. I reckon this is what you've thought of, but I don't know of any more efficient way, excepting that I'd be more inclined to do this when I need the value, and not store it as bits in memory. Christian Graus - Microsoft MVP - C++
I still wonder if there's a quicker way - but speed is not essential for what I am doing - reading mp3 header information. Jim