
Ich werd nochmal meinen Code überarbeiten.
Code: Alles auswählen
Macro Happy
;-)
EndMacro
Happy End
Code: Alles auswählen
, sep.s="."
Code: Alles auswählen
"."
Code: Alles auswählen
sep
AND51 gehts um EffizienzHellhound66 hat geschrieben:Gehts hier um Speed oder um Kompaktheit?
Code: Alles auswählen
Procedure.s FormatByteSize(zahl.q)
Protected l.l, y.l, i.l, x.l, z.l, buff$, num$
num$=StrQ(zahl)
buff$=Space(30)
l=Len(num$)
y=l-(l/3)*3
For i=y To l-1
PokeB(@buff$+z,PeekB(@num$+i))
z+1 : x+1
If x=3
x=0
If i<>l
PokeB(@buff$+z,32)
z+1
EndIf
EndIf
Next
ProcedureReturn ReplaceString(Trim(Left(num$,y)+" "+buff$)," ",".")
EndProcedure
Debug FormatByteSize(1)
Debug FormatByteSize(12)
Debug FormatByteSize(123)
Debug FormatByteSize(1234)
Debug FormatByteSize(12345)
Debug FormatByteSize(123456)
Debug FormatByteSize(1234567)
Debug FormatByteSize(12345678)
Debug FormatByteSize(123456789)
Debug FormatByteSize(1234567890)
Debug FormatByteSize(4294967295)
Nicht nur. Vielmehr auch um Fehlerfreiheit und das ist wohl auch erstmal das wichtigste.Gehts hier um Speed oder um Kompaktheit?
Wat jibbet denn zu jewinnen?Jungs, wo bleibt denn bei euch das frei wählbare Tausendertrennzeichen?
Oder habe ich das Bild umsonst gepostet? Ich finde, das ist schon ein
Bestandteil des "Wettbewerbs"
Genügt dir mein Respekt etwa nicht?al90 hat geschrieben:Wat jibbet denn zu jewinnen?
Code: Alles auswählen
Macro Happy
;-)
EndMacro
Happy End
Das Stimmt!ts-soft hat geschrieben:AND51 gehts um EffizienzHellhound66 hat geschrieben:Gehts hier um Speed oder um Kompaktheit?
Grrr, das stimmt nicht!ts-soft hat geschrieben: Das er oftmals davon ausgeht, das, je kürzer, je schneller, weiß ich auch nicht
Code: Alles auswählen
Procedure.s tausendertrennzeichen(zahl.q, separator.s=".")
Protected zahl$=StrQ(zahl), start.l=Len(zahl$)%3, res.s=PeekS(@zahl$, start), n.l
For n=start To Len(zahl$)-start-1 Step 3
res+separator+PeekS(@zahl$+n, 3)
Next
ProcedureReturn LTrim(RemoveString(" "+res, " "+separator))
EndProcedure
Debug tausendertrennzeichen(12345678)
Code: Alles auswählen
Macro Happy
;-)
EndMacro
Happy End
Code: Alles auswählen
Procedure.s FormatByteSize(zahl.q)
Protected l.l, y.l, i.l, x.l, z.l, buff$, num$
Protected size=SizeOf(Character)
num$=StrQ(zahl)
buff$=Space(30)
l=Len(num$)
y=l-(l/3)*3
For i=y To l-1
PokeC(@buff$+z*size,PeekC(@num$+i*size))
z+1 : x+1
If x=3
x=0
If i<>l
PokeC(@buff$+z*size,32)
z+1
EndIf
EndIf
Next
ProcedureReturn ReplaceString(Trim(Left(num$,y)+" "+buff$)," ",".")
EndProcedure
Code: Alles auswählen
i*size
Code: Alles auswählen
Procedure.s FormatByteSize(zahl.q,ch.s)
Protected l.l, y.l, i.l, x.l, z.l, buff$, num$
Protected Size=SizeOf(Character)
num$=StrQ(zahl)
buff$=Space(30)
l=Len(num$)
y=l-(l/3)*3
For i=y To l-1
PokeC(@buff$+z*Size,PeekC(@num$+i*Size))
z+1 : x+1
If x=3
x=0
If i<>l
PokeC(@buff$+z*Size,32)
z+1
EndIf
EndIf
Next
ProcedureReturn ReplaceString(Trim(Left(num$,y)+" "+buff$)," ",ch)
EndProcedure
Procedure.s FormatByteSize2(zahl.q,ch.c)
Protected l.l, y.l, i.l, x.l, z.l, buff$, num$
Size=SizeOf(Character)
num$ = StrQ(zahl)
l = Len(num$)
y = (l-1)/3
buff$ = Space(l+y+1)
*BuffPTR.Character = @buff$+(l+y)*Size
*NumPtr.Character = @num$+l*Size
For i=0 To l
*BuffPTR\C = *NumPtr\C ;PokeC(@buff$+z*Size,PeekC(@num$+i*Size))
*BuffPTR - Size
*NumPtr - Size
If(x=3)
If(i=l)
Break
EndIf
x=0
*BuffPTR\C = ch ;PokeC(@buff$+z*Size,32)
*BuffPTR - Size
EndIf
x+1
Next
ProcedureReturn buff$
EndProcedure
Delay(500)
#Iterations = 1000000
time.l = ElapsedMilliseconds()
For i = 1 To #Iterations
FormatByteSize(12345678901234,".")
Next
OldFunc.l = ElapsedMilliseconds()-time
time.l = ElapsedMilliseconds()
For i = 1 To #Iterations
FormatByteSize2(12345678901234,'.')
Next
NewFunc.l = ElapsedMilliseconds()-time
MessageRequester("SpeedTest","Alte Funktion : "+Str(OldFunc)+#CRLF$+"Neue Funktion : "+Str(NewFunc),#PB_MessageRequester_Ok)
Code: Alles auswählen
Macro Happy
;-)
EndMacro
Happy End