View Full Version : QBitArray (the smallest unit of them all)
baray98
29th September 2007, 07:55
I have a buffer (char [variable]) and i want to inspect this bit by bit hence like a big bit array.
Is it possible to use a QBitArray in this case? if so please give me snippet of how to make this buffer into a bit array.
baray98
p.s. "variable" is known before doing all these processing
wysota
29th September 2007, 09:05
I wouldn't do that. The class seems to be a bit crude to operate on. For instance you'd have to copy your array bit by bit into the object thus iterating it manually first, so I think there is no sense to double the work.
marcel
29th September 2007, 09:18
You can work directly on the char array:
bool bit( char c, int b)
{
char mask = (1 << b);
return (c&mask==mask)?true:false;
}
where b is the bit you want to test( 0 to 7).
Returns true if the bit is set, false otherwise.
baray98
29th September 2007, 14:16
my main goal is to read a char buffer (variable size) as K size units, where k can 1 bit to 32 bits. example if i am given a buffer pointer and a K of 2 then I will go through the buffer and read them 2 bits at time. please guide me on how to implement these in a very efficient manner.
baray98
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.