View previous topic :: View next topic |
Author |
Message |
ejeuler
Joined: 18 May 2011 Posts: 2
|
Integer expression to boolean Operator !! |
Posted: Wed May 18, 2011 4:27 pm |
|
|
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: 1934 Location: Norman, OK
|
|
Posted: Wed May 18, 2011 5:14 pm |
|
|
...
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
|
|
|
ejeuler
Joined: 18 May 2011 Posts: 2
|
|
Posted: Wed May 18, 2011 7:46 pm |
|
|
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
|
|
Posted: Wed May 18, 2011 11:06 pm |
|
|
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. |
|
|
|