H. S. Teoh:

In some cases you can remove such casts using a union (like a union of one ulong and a uint[2]).

Using a union here is not a good idea, because the results depend on the endianness of the machine! It's better to just use (a & 0xFFFF) or (a >> 16) instead.

Better to avoid magic constants, you can forget one F or something. In this case you have to use 0xFFFF_FFFFu. This is safer and more readable:

a & uint.max

Bye,
bearophile

Reply via email to