-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogic.vb
100 lines (70 loc) · 2.62 KB
/
Logic.vb
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
Public Class Logic
Shared Sub _NOT(ByRef input As Byte())
For i As Integer = 0 To input.Length - 1 Step 1
input(i) = Not input(i)
Next i
End Sub
Shared Function _AND(ByVal input0 As Byte(), ByVal input1 As Byte()) As Byte()
If input0.Length > input1.Length Then
Dim out(input0.Length - 1) As Byte
For i As Integer = 0 To input1.Length - 1 Step 1
out(i) = input0(i) And input1(i)
Next i
For i As Integer = input1.Length To input0.Length - 1 Step 1
out(i) = 0
Next i
Return out
Else
Dim out(input1.Length - 1) As Byte
For i As Integer = 0 To input0.Length - 1 Step 1
out(i) = input1(i) And input0(i)
Next i
For i As Integer = input0.Length To input1.Length - 1 Step 1
out(i) = 0
Next i
Return out
End If
End Function
Shared Function _OR(ByVal input0 As Byte(), ByVal input1 As Byte()) As Byte()
If input0.Length > input1.Length Then
Dim out(input0.Length - 1) As Byte
For i As Integer = 0 To input1.Length - 1 Step 1
out(i) = input0(i) Or input1(i)
Next i
For i As Integer = input1.Length To input0.Length - 1 Step 1
out(i) = input0(i)
Next i
Return out
Else
Dim out(input1.Length - 1) As Byte
For i As Integer = 0 To input0.Length - 1 Step 1
out(i) = input1(i) Or input0(i)
Next i
For i As Integer = input0.Length To input1.Length - 1 Step 1
out(i) = input1(i)
Next i
Return out
End If
End Function
Shared Function _XOR(ByVal input0 As Byte(), ByVal input1 As Byte()) As Byte()
If input0.Length > input1.Length Then
Dim out(input0.Length - 1) As Byte
For i As Integer = 0 To input1.Length - 1 Step 1
out(i) = input0(i) Xor input1(i)
Next i
For i As Integer = input1.Length To input0.Length - 1 Step 1
out(i) = input0(i)
Next i
Return out
Else
Dim out(input1.Length - 1) As Byte
For i As Integer = 0 To input0.Length - 1 Step 1
out(i) = input1(i) Xor input0(i)
Next i
For i As Integer = input0.Length To input1.Length - 1 Step 1
out(i) = input1(i)
Next i
Return out
End If
End Function
End Class