On 10/19/2016 08:01 PM, Marek Vasut wrote:
> You might like 0xfffffffc better, but that does require that you count
> f's appropriately for the type.  That's why I like -4: it's obvious (or
> should be) that it masks to a multiple of 4, and type promotion extends
> bits to the left as needed for the type of the other AND argument.
But then you can also use ~3 , right ?

Yes.

In which case, you'd avoid doing
bitwise operations with negative numbers, which is nice.

Eh.  Since ~3 == -4, ~3 is a negative number.  So it's a false argument.

(C triviallities aside, such as the fact that there are no negative constants, only positive constants to which unary negation may be applied.)

The reason I like -4 is that it aligns to 4, spelled the same way.



r~

Reply via email to