Do you agree that this code, for a 16 or 32 bit size_t target, can omit the and'ing because the cast does the same thing?
(uint16_t)(x & 0xffff)
where x is a uint32_t
Or can one assume the compiler will omit the AND operation whilst doing the cast? Or is it better to not assume such?
(I'm curious as this is part of size-limited code no matter the target CPU)
(uint16_t)(x & 0xffff)
where x is a uint32_t
Or can one assume the compiler will omit the AND operation whilst doing the cast? Or is it better to not assume such?
(I'm curious as this is part of size-limited code no matter the target CPU)
Last edited: