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