Correct typecasting of unsigned integers