unsigned int econv(unsigned int from) {
unsigned int value = from;
std::cout << std::hex << "original:" << from << " : "<< sizeof(value) << std::endl;
value |= (from & 0xFF000000) >> 24;
// allocate from the original first byte, move it to the end and through "OR" apply changes
std::cout << from << ">> 24 " << value << std::endl;
value |= (from & 0x00FF0000) >> 8;
// allocate the second byte and shift it to 3rd place
std::cout << from << ">> 8 " << value << std::endl;
value |= (from & 0x0000FF00) << 8;
// if the shift to the right all okay, then shifted to the left of the problem - value is not changed here at all, am I doing it wrong?
std::cout << from << "<< 8 " << value << std::endl;
value |= (from & 0x000000FF) << 24;
// right shift the last byte in the 1st position is also not reflected in the result
std::cout << from << "<< 24 " << value << std::endl;
return value;
}
unsigned value = 0
;Find more questions by tags C++
"It is necessary to draw on a blank canvas"
"It is necessary to draw on a blank canvas"
"It is necessary to draw on a blank canvas" - gino.Stark23 commented on June 10th 19 at 16:11