ROBOTC.net forums
http://robotc.net/forums/

What does the exclamation point mean in code?
http://robotc.net/forums/viewtopic.php?f=1&t=10765
Page 1 of 1

Author:  LoJac10 [ Tue Mar 24, 2015 2:01 pm ]
Post subject:  What does the exclamation point mean in code?

What does the exclamation point mean in the following code?

else if((!(SensorValue[leftlight] > lightSensorThreshold)

in other words how is the above code different from the code below

else if(((SensorValue[leftlight] > lightSensorThreshold)

thanx.

Author:  mightor [ Tue Mar 24, 2015 3:52 pm ]
Post subject:  Re: What does the exclamation point mean in code?

Code:
if(!(SensorValue[leftlight] > lightSensorThreshold))

means if SensorValue[leftlight] is NOT greater than lightSensorThreshold, which is the same as
Code:
if(SensorValue[leftlight] <= lightSensorThreshold)

!, which is also pronounced as "bang" or "not" will invert the statement following it.
= Xander

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/