mirror of
https://github.com/lubosz/overte.git
synced 2025-04-27 09:35:28 +02:00
Merge pull request #2389 from thagale/master
Potential fix for: closes #2386
This commit is contained in:
commit
08c5c49891
1 changed files with 16 additions and 8 deletions
|
@ -130,14 +130,22 @@ void outputBits(unsigned char byte, QDebug* continuedDebug) {
|
|||
}
|
||||
|
||||
int numberOfOnes(unsigned char byte) {
|
||||
return (byte >> 7)
|
||||
+ ((byte >> 6) & 1)
|
||||
+ ((byte >> 5) & 1)
|
||||
+ ((byte >> 4) & 1)
|
||||
+ ((byte >> 3) & 1)
|
||||
+ ((byte >> 2) & 1)
|
||||
+ ((byte >> 1) & 1)
|
||||
+ (byte & 1);
|
||||
|
||||
static const int nbits[256] = {
|
||||
0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,
|
||||
4,3,4,4,5,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,
|
||||
4,5,3,4,4,5,4,5,5,6,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,
|
||||
3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,
|
||||
4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,1,2,2,3,2,3,3,
|
||||
4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,
|
||||
3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,
|
||||
6,6,7,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,
|
||||
4,5,5,6,5,6,6,7,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,
|
||||
6,5,6,6,7,5,6,6,7,6,7,7,8
|
||||
};
|
||||
|
||||
return nbits[(unsigned char) byte];
|
||||
|
||||
}
|
||||
|
||||
bool oneAtBit(unsigned char byte, int bitIndex) {
|
||||
|
|
Loading…
Reference in a new issue