@@ -163,9 +163,9 @@ Can only be applied to values of type [`Int{:tact}`][int]:
163
163
164
164
``` tact
165
165
let two: Int = 2;
166
- two * two; // 4
167
- 0 * 1_000_000_000; // 0
168
- -1 * 5; // -5
166
+ two * two; // 4
167
+ 0 * 1_000_000_000; // 0
168
+ -1 * 5; // -5
169
169
170
170
pow(2, 255) * pow(2, 255); // build error: integer overflow!
171
171
```
@@ -178,12 +178,12 @@ Can only be applied to values of type [`Int{:tact}`][int]:
178
178
179
179
``` tact
180
180
let two: Int = 2;
181
- two / 2; // 1
182
- two / 1; // 0
183
- -1 / 5; // -1
184
- -1 / -5; // 0
185
- 1 / -5; // -1
186
- 1 / 5; // 0
181
+ two / 2; // 1
182
+ two / 1; // 0
183
+ -1 / 5; // -1
184
+ -1 / -5; // 0
185
+ 1 / -5; // -1
186
+ 1 / 5; // 0
187
187
```
188
188
189
189
#### Modulo, ` % ` [ #binary-modulo]
@@ -197,9 +197,9 @@ let two: Int = 2;
197
197
two % 2; // 0
198
198
two % 1; // 1
199
199
200
- 1 % 5; // 1
200
+ 1 % 5; // 1
201
201
-1 % 5; // 4
202
- 1 % -5; // -4
202
+ 1 % -5; // -4
203
203
-1 % -5; // -1
204
204
```
205
205
@@ -230,7 +230,7 @@ Can only be applied to values of type [`Int{:tact}`][int]:
230
230
``` tact
231
231
let two: Int = 2;
232
232
two + 2; // 4
233
- -1 + 1; // 0
233
+ -1 + 1; // 0
234
234
235
235
pow(2, 254) + pow(2, 254); // 2 * 2^254
236
236
pow(2, 255) + pow(2, 255); // build error: integer overflow!
@@ -246,7 +246,7 @@ Can only be applied to values of type [`Int{:tact}`][int]:
246
246
``` tact
247
247
let two: Int = 2;
248
248
two - 2; // 0
249
- -1 - 1; // -2
249
+ -1 - 1; // -2
250
250
251
251
pow(2, 254) - pow(2, 254); // 0
252
252
pow(2, 255) - pow(2, 255); // 0
@@ -266,8 +266,8 @@ Can only be applied to values of type [`Int{:tact}`][int]:
266
266
``` tact
267
267
let two: Int = 2;
268
268
two >> 1; // 1
269
- 4 >> 1; // 2
270
- 5 >> 1; // 2, due to flooring of integer values
269
+ 4 >> 1; // 2
270
+ 5 >> 1; // 2, due to flooring of integer values
271
271
272
272
pow(2, 254) >> 254; // 1
273
273
```
@@ -288,8 +288,8 @@ Can only be applied to values of type [`Int{:tact}`][int]:
288
288
``` tact
289
289
let two: Int = 2;
290
290
two << 1; // 4
291
- 1 << 5; // 1 * 2^5, which is 32
292
- 2 << 5; // 2 * 2^5, which is 64
291
+ 1 << 5; // 1 * 2^5, which is 32
292
+ 2 << 5; // 2 * 2^5, which is 64
293
293
294
294
pow(2, 254) == (1 << 254); // true
295
295
pow(2, 254) == 1 << 254; // true, no parentheses needed due to higher precedence of >> over ==
@@ -313,8 +313,8 @@ Binary _greater than_ operator `>{:tact}` returns `true{:tact}` if the left oper
313
313
314
314
``` tact
315
315
let two: Int = 2;
316
- two > 2; // false
317
- -1 > -3; // true
316
+ two > 2; // false
317
+ -1 > -3; // true
318
318
```
319
319
320
320
#### Greater than or equal to, ` >= ` [ #binary-greater-equal]
@@ -323,8 +323,8 @@ Binary _greater than or equal to_ operator `>={:tact}` returns `true{:tact}` if
323
323
324
324
``` tact
325
325
let two: Int = 2;
326
- two >= 2; // true
327
- -1 >= -3; // true
326
+ two >= 2; // true
327
+ -1 >= -3; // true
328
328
```
329
329
330
330
#### Less than, ` < ` [ #binary-less]
@@ -333,8 +333,8 @@ Binary _less than_ operator `<{:tact}` returns `true{:tact}` if the left operand
333
333
334
334
``` tact
335
335
let two: Int = 2;
336
- two < 2; // false
337
- -1 < -3; // false
336
+ two < 2; // false
337
+ -1 < -3; // false
338
338
```
339
339
340
340
#### Less than or equal to, ` <= ` [ #binary-less-equal]
@@ -417,12 +417,12 @@ Can only be applied to values of type [`Int{:tact}`][int]:
417
417
418
418
``` tact
419
419
let two: Int = 2;
420
- two & 1; // 0
421
- 4 & 1; // 0
422
- 3 & 1; // 1
423
- 1 & 1; // 1
420
+ two & 1; // 0
421
+ 4 & 1; // 0
422
+ 3 & 1; // 1
423
+ 1 & 1; // 1
424
424
425
- 255 & 0b00001111; // 15
425
+ 255 & 0b00001111; // 15
426
426
0b11110000 & 0b00001111; // 15
427
427
```
428
428
@@ -444,11 +444,11 @@ Can only be applied to values of type [`Int{:tact}`][int]:
444
444
``` tact
445
445
let two: Int = 2;
446
446
two ^ 3; // 1
447
- 4 ^ 1; // 0
448
- 3 ^ 1; // 3
449
- 1 ^ 1; // 0
447
+ 4 ^ 1; // 0
448
+ 3 ^ 1; // 3
449
+ 1 ^ 1; // 0
450
450
451
- 255 ^ 0b00001111; // 240
451
+ 255 ^ 0b00001111; // 240
452
452
0b11110000 ^ 0b00001111; // 240
453
453
```
454
454
@@ -468,11 +468,11 @@ Can only be applied to values of type [`Int{:tact}`][int]:
468
468
``` tact
469
469
let two: Int = 2;
470
470
two | 1; // 3
471
- 4 | 1; // 5
472
- 3 | 1; // 3
473
- 1 | 1; // 1
471
+ 4 | 1; // 5
472
+ 3 | 1; // 3
473
+ 1 | 1; // 1
474
474
475
- 255 | 0b00001111; // 255
475
+ 255 | 0b00001111; // 255
476
476
0b11110000 | 0b00001111; // 255
477
477
```
478
478
@@ -491,9 +491,9 @@ Can only be applied to values of type [`Bool{:tact}`][bool]:
491
491
492
492
``` tact
493
493
let iLikeTact: Bool = true;
494
- iLikeTact && true; // true, evaluated both operands
495
- iLikeTact && false; // false, evaluated both operands
496
- false && iLikeTact; // false, didn't evaluate iLikeTact
494
+ iLikeTact && true; // true, evaluated both operands
495
+ iLikeTact && false; // false, evaluated both operands
496
+ false && iLikeTact; // false, didn't evaluate iLikeTact
497
497
```
498
498
499
499
### Logical OR, ` || ` [ #binary-logical-or]
0 commit comments