In <41**************************@posting.google.com >
ne*****@tokyo.com (Mantorok Redgormor) writes:
Should I avoid its use? It seems its use from alot of other posts that
I have read is discouraged because a discussion always begins on how
implementation defined behavior occurs with it.
~0 [ this is not well defined right? ]
[ if anyone ever used this in code it would not be portable? ]
~-1 [ well defined? ]
~25 [ well defined? ]
It is well defined on unsigned operands only. The result on signed
operands is implementation-defined, because the standard allows more than
one representation for negative values. Furthermore, depending on the C99
implementation, applying it to certain signed values may result in trap
representations (e.g. ~INT_MAX for two's complement and sign-magnitude
and ~0 for one's complement).
Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email:
Da*****@ifh.de