Im getting a slight math error in my program, which is causing problems in the rest of it, and i dont get why it is happening. in this part of the class, i did not overload the operators for built in types (i hope). if i did, please show me where
this function is meant to calculate the least number of bits needed to store a the number, which is stored in a deque <uint8_t> value as one value, so 0x123456 will be stored as {0x12, 0x34, 0x56}, and the output to integer.bits() should be 21
// all types here are standard, so i dont know whats going on
unsigned int bits(){
unsigned int out = value.size() << 3;
std::cout << out << " " << value.size() << " " << (value.size() << 3) << std::endl;
uint8_t top = 128;
while (!(value.front() & top)){
out--;
top >>= 1;
}
return out;
}
yet, this part is couting
8 1 8
16 2 16
...
and finally,
18 3 18
3*8is24, and in hex that’s0x18. You havestd::hexscattered about your code…