| |
|
|
p.specht
| Bitleisten (here in purem XProfan11) should as speicherplatz-sparende Version of massenhaften 2-Zustands-Save, about with the realization one speedy Primzahlenfilters* or the indexierten Löschvermerk of/ one data base serve.
the follow up Machwerk is a allererster attempt moreover, is quite slow. for the practice wären flottere Solutions, about with Memory-Variables and by Assembler or same by windows-API demand.
Window Title " Simulation of bit-Leisten through Long&-Arrays (beta)"
' Copyleft (CL) 2012-12 by P. Specht; OHNE GEWÄHR!
declare z$,z&,idx!,max!,dw&[],dwx&,bw&,bw1&,bitImLong&
huch:
cls:font 2:color 0,15
max!=fetch(" highest vorkommender bit-index [ex 0]?: ",max!)
if max!<0:Error():Print " negatives Indizes dzt. not vorgesehen! *** "
max!=0:waitinput :goto "huch"
endif
if max!>2147483615:Error():Print " Max.index dzt.2^31-32-1= 2147483615, wg. INT()"
max!=2147483615:waitinput :goto "huch"
endif
z&=int(max!/32+1):setsize dw&[],z&
Print " moreover get ";z&;" Long&-variables alloziert."
print " Probe: 32*";z&;"=";int(z&*32);" bit":print
REPEAT
again:
idx!=fetch(" bit-index: ",idx!)
if idx!>max!
Error()
print " ceiling ";int(max!);" overstepped! *** \n"
color 0,15:idx!=max!:goto "nochmal"
elseif idx!<0:Error():print " negatives Indizes are not vorgesehen! *** \n"
color 0,15:idx!=0:goto "nochmal"
endif
dwx&=int(idx!/32)
bitImLong&=int(idx!-dwx&*32)
bw&=@TestBit(dw&[dwx&],bitImLong&)
z$=" Long&["+st$(dwx&)+"] : bit["+st$(bitImLong&)+"] ?= "
bw1&=fetch(z$,bw&)
bw1&=(bw1&<>0)
if bw&<>bw1&: dw&[dwx&]=setbit(dw&[dwx&],bitImLong&,bw1&)
color 1,15:locate %csrlin-1,31
print ":bit[";int(idx!);"] is now ";bw1&:color 0,15
endif
print
if idx!>=max!
idx!=max!
print " *** warning: ceiling access! ***"
else
idx!=int(idx!)+1
endif
ENDWHILE
END
proc fetch :parameters txt$,idx! :declare z$
print txt$;int(idx!):locate %csrlin-1,len(txt$)+1:input z$
case %csrlin>19:cls
return if(z$="",idx!,val(z$))
endproc
proc Error
color 12,15
print " *** FEHLER:";
sound 500,100
endproc
Note: with Floating-Point-Ganzzahlen could one in the area +/- 9007199254740992 fehlerfrei bits indexieren, - takes to the Vorzeichenbit too yet with, then goes the area of 0 - 18 014 398 409 481 984. theoretical could one so one Eratosthenes-filter for ca. the first 720 Bio. Primzahlen set up (Geschätzte Primzahldichte something under 4%) - though: where Save we The 2048 Terabyte the Bitleiste? (from the Rechenzeit none To talk...). even if we Runlenght-Encoden is the still always vast... |
|
|
| Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'... | 06/16/21 ▲ |
|
|
|
|
p.specht
| Bibit-groin ========= for a Rechtecksmatrix-InPlace-Transposition was a status-Doppelbitleiste (Bibit-comb) with the possible Values {0,1,2,3} necessary. self-evident must one too the in the practice yet clever speed, but the principle works already time.
The operating the Machwerks is something gewöhnungsbedürftig (but letztendlich should the ohnehin the computer make): Einzugeben are always the index-worth, then becomes the is-status the relevanten Doppelbits displayed and can by the new status (0..3) supplant go.
Window Title "Bibit-groin from 2it-Bitgruppen z.B. for Bearbeitungsstatus-values 0,1,2,3"
'CopyLeft (CL) 2012-12ff by P. woodpecker. Jedwede Liability is particularly impossible!
randomize:font 2:Cls rnd(8^8)
Declare max&,idx&,wert&,lx&,bbiL&,in$
Print " Max.Bibit-Indexwert = ";:input max&
Declare bb&[max&/16]
Print " amount benötigter Longs: ";int(max&\16+1)
bb&[0]=rnd(4294967295):print " Test bb&[0]:Bibit-Idx:15__0: ";be$(bb&[0])
Repeat
print "\n Bibit-index: ";idx&,",",:input idx&
lx&=idx&\16:print " bb-idx=";lx&
bbiL&=(idx& mod 16)*2:print " bbiL&=";bbiL&
wert&=(bb&[lx&] & (3<<bbiL&))>>(bbiL&)
print " is:",wert&," should:",:input in$
if in$>""
wert&=val(in $) mod 4
bb&[lx&]=bb&[lx&] & (4294967295-(3<<bbiL&)) | (wert&<<bbiL&)
wert&=(bb&[lx&] & (3<<bbiL&))>>bbiL&
locate %csrlin-1,30:print "... is nun",wert&
endif
until 0
End
|
|
|
| Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'... | 06/16/21 ▲ |
|
|
|