File: operators.md

package info (click to toggle)
golang-github-d5-tengo 2.17.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,240 kB
  • sloc: makefile: 12
file content (193 lines) | stat: -rw-r--r-- 5,575 bytes parent folder | download
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# Operators

## Int

### Equality

- `(int) == (int) = (bool)`: equality
- `(int) != (int) = (bool)`: inequality

### Arithmetic Operators

- `(int) + (int) = (int)`: sum
- `(int) - (int) = (int)`: difference
- `(int) * (int) = (int)`: product
- `(int) / (int) = (int)`: quotient
- `(int) % (int) = (int)`: remainder
- `(int) + (float) = (float)`: sum
- `(int) - (float) = (float)`: difference
- `(int) * (float) = (float)`: product
- `(int) / (float) = (float)`: quotient
- `(int) + (char) = (char)`: sum
- `(int) - (char) = (char)`: difference

### Bitwise Operators

- `(int) & (int) = (int)`: bitwise AND
- `(int) | (int) = (int)`: bitwise OR
- `(int) ^ (int) = (int)`: bitwise XOR
- `(int) &^ (int) = (int)`: bitclear (AND NOT)
- `(int) << (int) = (int)`: left shift
- `(int) >> (int) = (int)`: right shift

### Comparison Operators

- `(int) < (int) = (bool)`: less than
- `(int) > (int) = (bool)`: greater than
- `(int) <= (int) = (bool)`: less than or equal to
- `(int) >= (int) = (bool)`: greater than or equal to
- `(int) < (float) = (bool)`: less than
- `(int) > (float) = (bool)`: greater than
- `(int) <= (float) = (bool)`: less than or equal to
- `(int) >= (float) = (bool)`: greater than or equal to
- `(int) < (char) = (bool)`: less than
- `(int) > (char) = (bool)`: greater than
- `(int) <= (char) = (bool)`: less than or equal to
- `(int) >= (char) = (bool)`: greater than or equal to

## Float

### Equality

- `(float) == (float) = (bool)`: equality
- `(float) != (float) = (bool)`: inequality

### Arithmetic Operators

- `(float) + (float) = (float)`: sum
- `(float) - (float) = (float)`: difference
- `(float) * (float) = (float)`: product
- `(float) / (float) = (float)`: quotient
- `(float) + (int) = (int)`: sum
- `(float) - (int) = (int)`: difference
- `(float) * (int) = (int)`: product
- `(float) / (int) = (int)`: quotient

### Comparison Operators

- `(float) < (float) = (bool)`: less than
- `(float) > (float) = (bool)`: greater than
- `(float) <= (float) = (bool)`: less than or equal to
- `(float) >= (float) = (bool)`: greater than or equal to
- `(float) < (int) = (bool)`: less than
- `(float) > (int) = (bool)`: greater than
- `(float) <= (int) = (bool)`: less than or equal to
- `(float) >= (int) = (bool)`: greater than or equal to

## String

### Equality

- `(string) == (string) = (bool)`: equality
- `(string) != (string) = (bool)`: inequality

### Concatenation

- `(string) + (string) = (string)`: concatenation
- `(string) + (other types) = (string)`: concatenation (after string-converted)

### Comparison Operators

- `(string) < (string) = (bool)`: less than
- `(string) > (string) = (bool)`: greater than
- `(string) <= (string) = (bool)`: less than or equal to
- `(string) >= (string) = (bool)`: greater than or equal to

## Char

### Equality

- `(char) == (char) = (bool)`: equality
- `(char) != (char) = (bool)`: inequality

### Arithmetic Operators

- `(char) + (char) = (char)`: sum
- `(char) - (char) = (char)`: difference
- `(char) + (int) = (char)`: sum
- `(char) - (int) = (char)`: difference

### Comparison Operators

- `(char) < (char) = (bool)`: less than
- `(char) > (char) = (bool)`: greater than
- `(char) <= (char) = (bool)`: less than or equal to
- `(char) >= (char) = (bool)`: greater than or equal to
- `(char) < (int) = (bool)`: less than
- `(char) > (int) = (bool)`: greater than
- `(char) <= (int) = (bool)`: less than or equal to
- `(char) >= (int) = (bool)`: greater than or equal to

## Bool

### Equality

- `(bool) == (bool) = (bool)`: equality
- `(bool) != (bool) = (bool)`: inequality

## Bytes

### Equality

Test whether two byte array contain the same data. Uses
[bytes.Compare](https://golang.org/pkg/bytes/#Compare) internally.

- `(bytes) == (bytes) = (bool)`: equality
- `(bytes) != (bytes) = (bool)`: inequality

## Time

### Equality

Tests whether two times represent the same time instance. Uses
[Time.Equal](https://golang.org/pkg/time/#Time.Equal) internally.

- `(time) == (time) = (bool)`: equality
- `(time) != (time) = (bool)`: inequality

### Arithmetic Operators

- `(time) - (time) = (int)`: difference in nanoseconds (duration)
- `(time) + (int) = (time)`: time + duration (nanoseconds)
- `(time) - (int) = (time)`: time - duration (nanoseconds)

### Comparison Operators

- `(time) < (time) = (bool)`: less than
- `(time) > (time) = (bool)`: greater than
- `(time) <= (time) = (bool)`: less than or equal to
- `(time) >= (time) = (bool)`: greater than or equal to

## Array and ImmutableArray

### Equality

Tests whether two _(immutable)_ arrays contain the same objects.

- `(array) == (array) = (bool)`: equality
- `(array) != (array) = (bool)`: inequality
- `(array) == (immutable-array) = (bool)`: equality
- `(array) != (immutable-array) = (bool)`: inequality
- `(immutable-array) == (immutable-array) = (bool)`: equality
- `(immutable-array) != (immutable-array) = (bool)`: inequality
- `(immutable-array) == (array) = (bool)`: equality
- `(immutable-array) != (array) = (bool)`: inequality

### Concatenation

- `(array) + (array)`: return a concatenated array  

## Map and ImmutableMap

### Equality

Tests whether two _(immutable)_ maps contain the same key-objects.

- `(map) == (map) = (bool)`: equality
- `(map) != (map) = (bool)`: inequality
- `(map) == (immutable-map) = (bool)`: equality
- `(map) != (immutable-map) = (bool)`: inequality
- `(immutable-map) == (immutable-map) = (bool)`: equality
- `(immutable-map) != (immutable-map) = (bool)`: inequality
- `(immutable-map) == (map) = (bool)`: equality
- `(immutable-map) != (map) = (bool)`: inequality