forked from LegoGMI/ManualeGM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path401_04_expressions.html
92 lines (78 loc) · 2.47 KB
/
401_04_expressions.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Expressions</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body background="images/back.gif">
<!--START-->
<h3>Expressions</h3>
Expressions can be real numbers (e.g. 3.4), hexadecimal numbers, starting
with a $ sign (e.g. $00FFAA), strings between single or
double quotes (e.g. 'hello' or “hello”) or more complicated
expressions. (Note that strings can run over multiple lines!)
For expressions, the following binary operators exist (in
order of priority):
<ul>
<li>&& || ^^: combine Boolean values (&& = and, || = or,
^^ = xor)</li>
<li>< <= == != > >=: comparisons, result in true (1) or
false (0)</li>
<li>| & ^: bitwise operators (| = bitwise or, & = bitwise and, ^
= bitwise xor)</li>
<li><< >>: bitwise operators (<< = shift left, >
> = shift right)</li>
<li>+ -: addition, subtraction</li>
<li>* / div mod: multiplication, division, integer division, and modulo
</li>
</ul>
<p>
Note that
value of <tt>x div y</tt> is the value of <tt>x/y</tt> rounded in the direction of zero to the nearest integer.
The <tt>mod</tt> operator returns the remainder obtained by dividing its operands.
In other words, <tt>x mod y = x - (x div y) * y</tt>.
Also, the following unary operators exist:
<ul>
<li>!: not, turns true into false and false into true</li>
<li>-: negates the next value</li>
<li>~: negates the next value bitwise</li>
</ul>
As values you can use numbers, variables, or functions that return a
value. Sub-expressions can be placed between brackets. All operators work
for real values. Comparisons also work for strings and + concatenates
strings. (Please note that, contrary to certain languages, both arguments
to a Boolean operation are always computed, even when the first argument
already determines the outcome.)
<p>
<b>Example</b>
<p>
Here is an example with some assignments.
<p>
<blockquote>
<pre>
{
x = 23;
color = $FFAA00;
str = 'hello world';
y += 5;
x *= y;
x = y << 2;
x = 23*((2+4) / sin(y));
str = 'hello' + " world";
b = (x < 5) && !(x==2 || x==4);
}
</pre>
</blockquote>
<!--END-->
</body>
</html>
<!-- KEYWORDS
hexadecimal numbers
expressions
operators
binary operators
unary operators
bitwise operators
boolean operators
logical operators
-->