-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharithmetic_ops.bscript
More file actions
111 lines (89 loc) Β· 2.01 KB
/
arithmetic_ops.bscript
File metadata and controls
111 lines (89 loc) Β· 2.01 KB
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
// Arithmetics
OP_1ADD β
// - 1 is added to the input
// => OP_1ADD
// => STACK = [ 0x02 0x01 ]
// ...
// STACK = [ 0x03 0x01 ]
OP_1SUB β
// - 1 is subtracted from the input
// => OP_1SUB
// => STACK = [ 0x02 0x01 ]
// ...
// STACK = [ 0x01 0x01 ]
OP_NEGATE β
// - sign of input is flipped
// => OP_NEGATE
// => STACK = [ 0x01 0x02 ]
// ...
// STACK = [ 0x-1 0x02 ]
OP_ABS β
// - The input is made positive.
// => OP_ABS
// => STACK = [ 0x-1 ]
// ...
// STACK = [ 0x01 ]
OP_NOT β
// - If the input is 0 or 1, it is flipped. Otherwise the output will be 0.
// => OP_NOT
// => STACK = [ 0x00 ]
// ...
// STACK = [ 0x01 ]
OP_0NOTEQUAL β
// - Returns 0 if the input is 0. 1 otherwise.
/****
stack format :
[ ]
[ b ]
[ a ]
****/
OP_ADD β
// - a is added to b.
// i/p -> a b
OP_SUB β
// - b is subtracted from a
// i/p -> a b
OP_BOOLAND β
// - If both a and b are not 0, the output is 1. Otherwise 0.
// i/p -> a b
OP_BOOLOR β
// - If a or b is not 0, the output is 1. Otherwise 0.
// - i/p -> a b
OP_NUMEQUAL β
// - Returns 1 if the numbers are equal, 0 otherwise.
// - i/p -> a b
OP_NUMEQUALVERIFY β
// - Same as OP_NUMEQUAL, but runs OP_VERIFY afterward.
// - i/p -> a b
OP_NUMNOTEQUAL β
// - Returns 1 if the numbers are not equal, 0 otherwise.
// - i/p -> a b
OP_LESSTHAN β
// - Returns 1 if a is less than b, 0 otherwise.
// - i/p -> a b
OP_GREATERTHAN β
// - Returns 1 if a is greater than b, 0 otherwise.
// - i/p -> a b
OP_LESSTHANOREQUAL β
// - Returns 1 if a is less than or equal to b, 0 otherwise.
// - i/p -> a b
OP_GREATERTHANOREQUAL β
// - Returns 1 if a is greater than or equal to b, 0 otherwise.
// - i/p -> a b
OP_MIN β
// - Returns the smaller of a and b.
// - i/p -> a b
OP_MAX β
// - Returns the larger of a and b.
// - i/p -> a b
OP_WITHIN β
// - Returns 1 if x is within the specified range (left-inclusive), 0 otherwise.
// - i/p -> x min max
// => 0 5 4 OP_WITHIN
// => STACK :
// [ 4 ]
// [ 5 ]
// [ 0 ]
// ...
// STACK = [ 1 ]
// => 4 is within range [0,5)