Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > bitwise not operator

Reply
Thread Tools

bitwise not operator

 
 
Mantorok Redgormor
Guest
Posts: n/a
 
      10-01-2003
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? ]

etc..
 
Reply With Quote
 
 
 
 
Dan Pop
Guest
Posts: n/a
 
      10-01-2003
In <(E-Mail Removed) > http://www.velocityreviews.com/forums/(E-Mail Removed) (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: (E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bitwise Not Operator aleksa C Programming 5 06-26-2012 07:17 PM
Bitwise NOT operator ( ~ ) Matt Kruse Javascript 3 05-16-2009 10:49 PM
Equivalence in use of bitwise | operator and + operator Ioannis Vranos C++ 8 11-14-2008 11:03 PM
How to calculate size of an int without using the sizeof operator but using bitwise operator Manish_Ganvir C Programming 13 02-14-2005 07:24 PM
Bitwise operator question... littlehobo C++ 10 10-01-2003 02:40 PM



Advertisments