Overview

This is all the operators and keywords supported by Acs as well as a basic description of each. You will have to find out for yourself all the different ways you can use. If you have some background in C/C++ then you will be able to pick up on this fast as much of it is the same.

Operators

These are all the operators supported by Acs.

'=' (binary)

Assignment Operator
This operator takes the value on the right and then stores it into the variable on the left. Unless an expression is being passed directly to a function or script then it must have some sort of an assignment operator associated to it.

Basic usage:

x = 2;

'+' (binary)

Addition Operator
Adds two numbers together

Basic usage:

z = x + y;

If you want to add a number back into a variable then see the '+=' operator.

'-' (unary)

Sign Change Operator
When used in front of a number it changes the sign of that variable.

Basic usage:

y = -x;

'-' (binary)

Subtraction Operator
This subtracts two integers from each other.

Basic usage:

z = x - y;

If you want to subract a number back into a variable then see the '-=' operator.

'*' (binary)

Multiplication Operator
This multiplies two numbers together.

Basic usage:

z = x * y;

If you want to multiply a number back into a variable then see the '*=' operator.

'/' (binary)

Division Operator
This divides two numbers together. Note that since ACS does not support floating point you can only get the integer portion of the result; the decimal part is cut off. Also be careful not to divide by zero as this will cause an error.

Basic usage: (Where y is non-zero)

z = x / y;

If you want to divide a number back into a variable then see the '/=' operator.

'%' (binary)

Modulous Operator
This operator performs a division operation on two values and returns the remainder of the operation (if any). For example, in math 10/3 is 3R1 so in acs 10 / 3 would return 3 and 10 % 3 would return 1. Basic usage: (Where y is non-zero)

z = x % y;

If you want to mod a number back into a variable then see the '%=' operator.

'&' (binary)

Bitwise AND Operator
This operator takes the bits of the left and right side and logically ANDs them together. See the following table:

    | p & q
p q |
0 0 |   0
0 1 |   0
1 0 |   0
1 1 |   1

A bit in the resulting value will only be 1 if the corresponding bits in both input values are also 1.

For example, 9 & 10 would result in 8, because 1001 (9) & 1010 (10) = 1000 (8). The most common usage for this operator is to check whether certain bits in a value are set.

Basic usage:

z = x & y;

In a conditional statement:

if (x & y) { statement }

If you want to logically AND the whole statement rather than each bit individually then see the '&&' operator. If you want to logically AND a number back into a variable then see the '&=' operator.

'|' (binary)

Bitwise OR Operator
This operator takes the bits of two numbers and logically ORs them together. See the following table: The OR truth table:

    | p | q
p q |
0 0 |   0
0 1 |   1
1 0 |   1
1 1 |   1

A bit in the resulting value will be 1 if either or both of the corresponding bits in the input values are 1. If both bits are 0, the resulting bit will also be 0.

For example, 9 | 10 would result in 11 because 1001 (9) | 1010 (10) = 1011 (11). The most common usage is to set a particular bit within a value.

Basic usage:

z = x | y;

If you want to logically OR a whole statement rather than each bit then see the '||' operator. If you want to logically OR a number back into a variable then see the '|=' operator.

'^' (binary)

Bitwise XOR Operator (sometimes refered to as EOR as well)
This is the exclusive-or operator and logically XORs the bits of two numbers together. See the following table:

    | p ^ q
p q |
0 0 |   0
0 1 |   1
1 0 |   1
1 1 |   0

A bit in the resulting value will be 1 only if the corresponding bits in the input values are different (0 & 1 or 1 & 0). If the input bits are the same, the bit in the resulting value will be 0.

For example, 9 ^ 10 will return 3 because 1001 (9) ^ 1010 (10) = 0011 (3).

Basic usage:

z = x ^ y;

If you want to logically XOR a number back into a variable then you should see the '^=' variable.

'~' (unary)

Bitwise NOT Operator.
This logically NOTs every bit in the number. The NOT truth table:

  | ~p
p |
0 |  1
1 |  0

As you can see it returns a true if false and a false if true. So if you logically NOT 7 then you get 8 (actually since integers in ACS are 32 bits and not 4 you actually get a very big negative number but you should be able to get the point) becase ~0 1 1 1 = 1 0 0 0 Basic usage:

y = ~x;

If you want to logically NOT a whole statement rather than each bit then see the '!' operator. If you want to logically NOT a variable and then store it back into itself then you need to do it the long way:

x = ~x;

'<<' (binary)

Bitwise Left Shift Operator
This operator takes all the bits on the left and shifts them by the number on the right. So if you have 7 and left shift it 1 then you have 14 because 0 1 1 1 << 1 = 1 1 1 0.

Note: this is exactly the same thing as multibling the number on the left by the cooresponding power of 2 on the left, so 4 << 3 = 32 because 2^3 is 8 and 8 by 4 is 32 but instead of multipling 4 * 8 its faster to do 4 << 3.

Note 2: If you shift a bit off you lose it. Since we are dealing with 32 bit integers a 1 << 32 shift will cause the one bit to be shifted off the variable and you would be left with 0.

Basic usage:

z = x << y;

If you want to shift the bits of a variable left and store it back into itself then see the '<<=' operator.

'>>' (binary)

Bitwise Right Shift Operator
This is the same thing as the left shift operator but the exact opposite. It takes the number on the left and moves its bits right by the number on the right. So 6 >> 1 = 3 because 0 1 1 0 >> 1 = 0 0 1 1.

Note: this is exactly the same as dividing a number the cooresponding power of 2 but faster. So, 24 >> 3 = 3 because 2^3 is 8 and 24 / 8 = 3.

Note 2: if you shift the bits off the variable then you lose the bit. If you take 1 and shift it 1: 1 >> 1 then you have zero because the bit got shifted off.

Basic usage:

z x >> y;

If you want to shift the bits of a variable right and store it back into itself then see the '>>=' operator.

'==' (binary)

Relational Equals To Operator.
This compares two statements and then returns a true if they equal and a false if they don't. Basic usage:

z x == y;

'!=' (binary)

Relational Doesn't Equal To Operator
This compares two statements and then returns a true if the don't equal and false if they do. Basic usage:

z = x != y;

'>' (binary)

Relational Greater Than Operator
This compares two statements and then returns true if the value on the left is greater than the value on the right or false otherwise; if the two are equal, it will return false. Basic usage:

z = x > y;

'>=' (binary)

Relational Greater Than or Equal To Operator
This compares two statements and then returns true if the value on the left is greater than or equal to the value on the right or false otherwise. Basic usage:

z = x >= y;

'<' (binary)

Relational Less Than Operator
This compares two statements and then returns true if the value on the left is smaller than the value on the right or false otherwise; if the two are equal it will return false. Basic usage:

z = x < y;

'<=' (binary)

Relational Less Than or Equal To Operater
This compares two statements and then returns true if the value on the left is smaller than or equal to the value on the right, or false otherwise. Basic usage:

z = x <= y;

'&&' (binary)

Logical AND Operator
This operator compares two statements and returns true if both statements are true, or false if either or both are false. See the following table:

    | p & q
p q |
0 0 |   0
0 1 |   0
1 0 |   0
1 1 |   1

Note that since any non-zero number is true, then this returns true: 4 && 3 It's best used when linking together relational operators. Basic usage:

if (x && y) { statement }

It can also be used for assignement:

z = x && y

Linking together relational operators:

z = x == y && a != b

'||' (binary)

Logical OR Operator
This operator compares two statements and returns true if either or both statements are true, or false if both are false. See the following table:

    | p & q
p q |
0 0 |   0
0 1 |   1
1 0 |   1
1 1 |   1

Note that since any non-zero number is true, this will return a true statement: 4 || 0. It's best used when linking together relational operators. Basic usage:

if (x || y) { statement }

It can also be used for assignment:

z = x || y;

Linking together relational operators:

z = x == y || a != b

'!' (unary)

Logical NOT Operator
This operator gives the inverse condition of a statement. If placed before a true statement, it will return false, and vice versa. It's best used with relational operators and other logical operators.

Basic usage:

y = !x

Used in logical operators:

z = !(x && y) && (x || Y)

This statement will only be executed if a is false:

if (!a) { statement }

'+=' (binary)

Addition Assignment Operator
This operator takes the value on the right, adds it to the value of the variable on the left, and then stores it back into the variable. It is the equivalent of n = n + y. Basic usage:

x += y;

'-=' (binary)

Subtraction Assignment Operator
This operator takes the value on the right, subtracts it from the value of the variable on the left, and then stores it back into the variable. It is the equivalent of n = n - y. Basic usage:

x -= y;

'*=' (binary)

Multiplication Assignment Operator
This operator takes the value on the right, multiplies it to the value of the variable on the left, and then stores it back into the variable. It is the equivalent of n = n * y. Basic usage:

x *= y;

'/=' (binary)

Division Assignment Operator
This operator takes the value on the right, divides the value of the variable by it, and then stores it back into the variable. It is the equivalent of n = n /y.

Note: all the limitaions of the division operator carry over so see the '/' operator if you are not sure.

Basic usage:

x /= y;

'%=' (binary)

Modulous Assignment Operator
This operator takes the value on the right, divides the value of the varialbe by it, returns the remainder and then stores it back into the variable. It is the equivalent of n = n % y.

Note: if you are unsure on how this operatore works then see the modulous operator:, '%', for more info.

Basic usage:

x %= y;

'&=' (binary)

Bitwise AND Assignment Operator
This operator takes the value on the right, logically ANDs all the bits of it to the value of the variable on the left, and then stores it back into the variable. It is the equivalent of n = n & y.

Note: See the Bitwise AND, '&', operator for more info on how this operator works.

Basic usage:

x &= y;

'|=' (binary)

Bitwise OR Assignment Operator
This operator takes the value on the right, logically ORs all the bits of it to the value of the variable on the left, and then stores it back into the variable. It is the equivalent of n = n | y.

Note: See the Bitwise OR, '|', operator for more info on how this operator works.

Basic usage:

x |= y;

'^=' (binary)

Bitwise XOR Assignment Operator
This operator takes the value on the right, logically XORs all the bits of it to the value of the variable on the left, and then stores it back into the variable. It is the equivalent of n = n ^ y.

Note: See the Bitwise XOR, '^', operator for more info on how this operator works.

Basic usage:

x ^= y;

'<<=' (binary)

Bitwise Left Shift Assignment Operator
This operator takes the value on the right, shifts the bits of the value of the variable on the left by the that number, and then stores it back into the variable. It is the equivalent of n = n << y.

Note: See the Bitwise Left Shift, '<<', operator for more info on how this operator works.

Basic usage:

x <<= y;

'>>=' (binary)

Bitwise Right Shift Assignment Operator
This operator takes the value on the right, shifts the bits of the value of the variable on the right by that number, and then stores it back into the variable. It is the equivalent of n = n >> y.

Note: See the Bitwise Right Shift, '>>', operator for more info on how this operator works.

Basic usage:

x >>= y;

Note: more to come but thats as far as I have gotten so feel free to add to it as you see fit (keep in mind that comments, keywords and preproccessor directives still need to be done).