Im EditFeld steht bei mir eine lange zahlenfolge:
3284283612163875659871432659632986597321587632195
die 1sten 8 Zahlen kommen in a.
die darauf folgenden in b...... aber nicht alle auf einmal.
Zuvor... a sei 100%
Nun will ich gucken wieviel prozent b von a ist...
y:=b*100/a
z.B. a:=32842836;
b:=121638756598714326596;
laut delphi y=370366178483229%;
Laut WindowsTaschenRechner a*y/100=121638756598714187974,44
Wieso Diese abweichung???
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:
| procedure TForm1.Button1Click(Sender: TObject); var q,y,y2,y3,y4:extended; i,j,l:integer; k,u,buffer:string; begin k:=''; q:=0; y2:=2; u:='';
for i:=1 to 8 do k:=k+edit1.text[i]; for i:=length(k)+1 to (length(k)*2) do u:=u+edit1.text[i];
for j:=17 to length(edit1.text) do begin
u:=u+edit1.text[j]; // showmessage(floattostr((11159134480*32765798))); q:=strtofloat(k); y2:=strtofloat(u); y:=y2*100/q; // showmessage(floattostr(100*88680 //78453842 886803984637639% label1.Caption:=k; label2.Caption:=u; application.ProcessMessages; if (length (floattostr(y))< length(u) )
then showmessage(u +'='+floattostr(y)+'%'+ 'von' +k+' won='+inttostr((length(u)-length (floattostr(y)))));
end;
end; |