CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Integer expression to boolean Operator !!

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ejeuler



Joined: 18 May 2011
Posts: 2

View user's profile Send private message

Integer expression to boolean Operator !!
PostPosted: Wed May 18, 2011 4:27 pm     Reply with quote

Hi All,

I've found examples of CCS C code using a "!!" operator, and comments indicating this converts an integer expression to boolean representation. I can find no references to this operator in my PCM compiler manual, older and newer CCS compiler manuals, Nigel Gardner's PIC Micro MCU C book, or searches in this forum or Google. Can someone please point me to where this operator is documented?

Thanks much!

ejeuler
dyeatman



Joined: 06 Sep 2003
Posts: 1923
Location: Norman, OK

View user's profile Send private message

PostPosted: Wed May 18, 2011 5:14 pm     Reply with quote

...

Last edited by dyeatman on Wed May 18, 2011 8:34 pm; edited 2 times in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed May 18, 2011 7:24 pm     Reply with quote

Here is another forum thread that discuss the double-not:
http://stackoverflow.com/questions/248693/double-negation-in-c-code
ejeuler



Joined: 18 May 2011
Posts: 2

View user's profile Send private message

PostPosted: Wed May 18, 2011 7:46 pm     Reply with quote

Thanks PCM programmer....


That link had some excellent discussion points/suggestions regarding integer/boolean conversions.


Thank you for taking the time to share this info!

ejeuler
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed May 18, 2011 11:06 pm     Reply with quote

Quote:
comments indicating this converts an integer expression to boolean representation

By C specification, integer operands can be used in a boolean expression. So the construct would be pretty useless. The discussion is referring to reasons as avoiding warnings with some compilers, or is speculating that if might serve a purpose somehow.

With CCS, I remember cases, at least with V3.xxx compilers, where the construct would help as bug workaround. A logical "&&" of int1 operands had been partly carried out as a & of the respective memory bytes and a bitmask, evaluating always false.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group