Code: Select all
93 ms for finding 195400 occurrences of 'Jesus' in a 777 MB file composed of 200x 'bible.txt'
Code: Select all
93 ms for finding 195400 occurrences of 'Jesus' in a 777 MB file composed of 200x 'bible.txt'
The Big Crunch.Albert wrote:Whats the opposite of the "Big Bang"?
What do they call it , when the universe compresses back to a single star?
Code: Select all
screen 19
dim as ulongint vals1(0 to 99)
dim as ulongint vals2(0 to 99)
dim as ulongint vals3(0 to 99)
dim as string insa
dim as string insb
dim as string checka
dim as string checkb
dim as string checkc
dim as string outs
for a as longint = 0 to 255
insa=right("000"+str(a),3)
for b as longint = 0 to 255
insb=right("000"+str(b),3)
outs=insa+insb
'record digits 1 & 2
checka = mid(outs,1,2)
vals1(val(checka)) = 1
'record digits 3 & 4
checkb = mid(outs,3,2)
vals2(val(checkb)) = 1
'record digits 5 & 6
checkc = mid(outs,5,2)
vals3(val(checkc)) = 1
next
next
dim as longint count1
dim as longint count2
dim as longint count3
for a as longint = lbound(vals1) to ubound(vals1)
if vals1(a) = 1 then count1+=1
if vals2(a) = 1 then count2+=1
if vals3(a) = 1 then count3+=1
next
print
print "checking values 000,000 to 255,255"
print
print "places 1 & 2 tot = " ; count1
print "places 3 & 4 tot = " ; count2
print "places 5 & 6 tot = " ; count3
sleep
end
Code: Select all
Function Base256asciiToBase10 (Byref s As String, Byref u As Ulongint) As Integer '' return value = 1 if conversion overflows (Len(s) > 8)
Dim As Ubyte Ptr p = Cptr(Ubyte Ptr, @u)
Function = 0
For I As Integer = Len(s) - 1 To 0 Step -1
If p = @u + 1 Then
Function = 1
Exit For
End If
*p = s[I]
p += 1
Next I
End Function
Dim As Ulongint u1
Dim As String s1 = Chr(1) & Chr(0)
Print Base256asciiToBase10(s1, u1), u1
Sleep
I don't know exactly what you mean.Albert wrote:I think you already wrote it , but i need a converter , to convert base 256 ascii , to base 10.
Can you give me a link to it?
Code: Select all
screen 19
dim as string num=""
dim as string outputs=""
do
dim as longint size = 1000
num=""
for a as longint = 1 to size
num+=chr(int(rnd*256))
next
'print "converting number to decimal"
dim as string decimal = ""'num
for a as longint = 0 to len(num)-1 step 1
decimal+=right("000"+str(num[a]),3)
next
dim as string _12 = ""
dim as string _45 = ""
dim as string _36 = ""
for a as longint = 1 to len(decimal) step 6
_12+= mid(decimal,a+0,2)
_45+= mid(decimal,a+3,2)
_36+= mid(decimal,a+2,1) + mid(decimal,a+5,1)
next
'print "12 = " ; _12
'print "45 = " ; _45
'print "36 = " ; _36
dim as string bin_12 = ""
dim as string bin_45 = ""
for a as longint = 1 to len(_12) step 2
bin_12+= right(string(5,"0") + bin(val(mid(_12,a,2))),5)
bin_45+= right(string(5,"0") + bin(val(mid(_45,a,2))),5)
next
dim as string bin_36 = ""
for a as longint = 1 to len(_36) step 3
bin_36+= right(string(10,"0") + bin(val(mid(_36,a,3))),10)
next
dim as string out_12 = ""
dim as string out_45 = ""
for a as longint = 1 to len(bin_12) step 8
out_12+= chr(valulng("&B" + mid(bin_12,a,8)))
out_45+= chr(valulng("&B" + mid(bin_45,a,8)))
next
dim as string out_36 = ""
for a as longint = 1 to len(bin_36) step 8
out_36+= chr(valulng("&B" + mid(bin_36,a,8)))
next
outputs = out_12 + out_45 + out_36
print
print "input digits = " ; size
print "output digits = " ; len(outputs)
print "compression = " ; 100 - ( 100 / (size / len(outputs)) )
sleep
loop until inkey = chr(27)
end