Basics – Syntax and Operators

To create our own sketches, we need knowledge about syntax and operators.

Generally Operators

   
   +    Addition
   -    Subtraction
   *    Multiplication
   /    Division
   %    Modulo
   ++   Increment
   --   Decrement

Logical Operators

   ==   equal
   !=   unequal
   >    greater than
   =    greater than or equal 
   <=   less than or equal
   &&   Logical AND
   ||   Logical OR
   !    Not

Bit Operators:

   &     AND
   &=    AND
   |     OR
   |=    OR
   ^     XOR
   ^=    XOR
   ~     
   <<    Shift left   (Bit Shifting)
   <<=   Shift left   (Bit Shifting)    
   >>    Shift right  (Bit Shifting)
   >>=   Shift right  (Bit Shifting)

Example:

Unsigned int Value=4;                  // 4 = 0000 0100
Unsigned int Shift=2;

Value = Value << Shift;                // Result:  16 … 0001 0000
// or the same
Value <<=Shift;                            // Result:  16


True or False

Normally, you don’t have “true” or “false” as discrete values. What we have is:
The value 0 is “false“, all other values are “true“!

Example:

	(1 == 1) 	true
	(1 != 1)	false
	(i  = 1)   	true
	(i  = 0)   	false
	(i  = 1 + 1) 	true

	(i = 1)         true
  	(i = 0)         false
	(i = 2)         true

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s