diff --git a/c/ex3.c b/c/ex3.c index 2d4d54c..84ff9a3 100644 --- a/c/ex3.c +++ b/c/ex3.c @@ -4,9 +4,8 @@ static unsigned char reverse_byte(unsigned char c) { unsigned char res = 0; for (size_t i = 0; i < CHAR_BIT; ++i) { - res <<= 1; - res |= c & 1; - c >>= 1; + unsigned char bit = (c & (1 << i)); + res |= bit << (CHAR_BIT - i - 1); } return res; }