Data update
This commit is contained in:
parent
0df55f9f24
commit
aec8ed51b6
1045 changed files with 18889 additions and 2777 deletions
|
|
@ -0,0 +1,37 @@
|
|||
Sub toOctets(n As Integer, octets() As Integer)
|
||||
Dim As String s = Bin(n)
|
||||
Dim As Integer le = Len(s)
|
||||
Dim As Integer r = le Mod 7
|
||||
Dim As Integer d = le \ 7
|
||||
If (r > 0) Then
|
||||
d += 1
|
||||
s = Right("0000000" & s, 7 * d)
|
||||
End If
|
||||
For i As Integer = 0 To d - 2
|
||||
Redim Preserve octets(i+1) As Integer
|
||||
octets(i) = Val("&B1" & Mid(s, i * 7 + 1, 7))
|
||||
Next i
|
||||
octets(d - 1) = Val("&B0" & Mid(s, (d - 1) * 7 + 1, 7))
|
||||
End Sub
|
||||
|
||||
Function fromOctets(octets() As Integer) As Integer
|
||||
Dim As String s = ""
|
||||
For i As Integer = 0 To Ubound(octets)
|
||||
s &= Right("0000000" & Bin(octets(i)), 7)
|
||||
Next i
|
||||
Return Val("&B" & s)
|
||||
End Function
|
||||
|
||||
Dim As Integer tests(1) = {2097152, 2097151}
|
||||
Dim As Integer i
|
||||
For i = 0 To Ubound(tests)
|
||||
Dim As Integer octets()
|
||||
toOctets(tests(i), octets())
|
||||
Dim As String display = ""
|
||||
For j As Integer = 0 To Ubound(octets)
|
||||
display &= "0x" & Hex(octets(j), 2) & " "
|
||||
Next j
|
||||
Print tests(i); " -> "; display; "-> "; fromOctets(octets())
|
||||
Next i
|
||||
|
||||
Sleep
|
||||
Loading…
Add table
Add a link
Reference in a new issue