- This wiki is out of date, use the continuation of this wiki instead
Operators
From FenixWiki
(Difference between revisions)
| Revision as of 12:46, 14 November 2007 (edit) Sandman (Talk | contribs) m (→General) ← Previous diff |
Revision as of 12:49, 8 March 2008 (edit) (undo) Sandman (Talk | contribs) (→Example) Next diff → |
||
| Line 60: | Line 60: | ||
| == Example == | == Example == | ||
| <pre> | <pre> | ||
| - | Program operators; | ||
| Global | Global | ||
| int int_1 = 1; | int int_1 = 1; | ||
| Line 72: | Line 71: | ||
| byte b_5 = 5; | byte b_5 = 5; | ||
| byte b_12 = 12; | byte b_12 = 12; | ||
| + | End | ||
| + | |||
| + | Process Main() | ||
| Begin | Begin | ||
| Line 120: | Line 122: | ||
| Repeat | Repeat | ||
| frame; | frame; | ||
| - | Until(key( | + | Until(key(_ESC)) |
| End | End | ||
| Line 127: | Line 129: | ||
| This will result in something like:<br> | This will result in something like:<br> | ||
| - | + | {{Image | |
| + | | image = Operators.png | ||
| + | | caption = operator results | ||
| + | }} | ||
Revision as of 12:49, 8 March 2008
Contents |
List of Operators
General
| Operator | - Description |
| Type | - Get the ProcessTypeID of a ProcessType or define a new datatype. See Type. |
Maths
| Operator | - Description |
| + | - Addition. |
| - | - Deduction |
| * | - Multiplication. |
| / | - Division. |
Logic
| Operator | - Description |
| || | - OR. One or the other or both. |
| && | - AND. Both. |
| ^^ | - XOR. One or the other, but not both. |
| ! | - NOT. |
Bitwise
(Logical operation per bit.)
| Operator | - Description |
| | | - BOR. One or the other or both. |
| & | - BAND. Both. |
| ^ | - BXOR. One or the other, but not both. |
| ~ | - BNOT. |
Memory
| Operator | - Description |
| & | - OFFSET. Get the memory address of a variable. See pointer. |
| * | - POINTER. Get access to the variable a pointer is pointing to. See pointer. |
Example
Global
int int_1 = 1;
int int_3 = 3;
int int_4 = 4;
int someint = -5;
String somestring = "AAP";
String anotherstring = "BEER";
byte somebyte = 6;
signed byte sbyte = -2;
byte b_5 = 5;
byte b_12 = 12;
End
Process Main()
Begin
say("---------- maths");
say(int_3 + int_4);
say(int_3 * int_4 + 1);
say("---------- strings with numerical datatypes");
say(somestring + anotherstring);
say(somestring + ": " + int_3);
say(anotherstring + ": " + int_3*sbyte);
say("---------- mixed numberical types and typecasting");
say(somebyte+someint);
say((signed byte)someint);
say((unsigned byte)someint);
say("---------- logic");
say(int_1&&int_4);
say(int_4==int_3+int_1);
say(!(somestring==anotherstring));
say("---------- bitwise");
say(b_5|b_12); // 00000101
// 00001100
// -------- |
// 00001101 = 13
say(b_5&b_12); // 00000101
// 00001100
// -------- &
// 00000100 = 4
say(b_5^b_12); // 00000101
// 00001100
// -------- ^
// 00001001 = 9
say(~b_12); // 00001100
// -------- ~
// 11110011 = 243
Repeat
frame;
Until(key(_ESC))
End
Used in example: say()
This will result in something like:
|

