题意不是很清楚,我按照自己的理解编了个例子如下:
//该函数在Delphi4 up3 + Win98 SE 环境下调试通过(未严格测试)。
//返回值为累计余数串(除到商为零止)
function LongStrDiv(const DidStr{被除数串},DivStr{除数串}:string):string;
procedure GetRemainderStr(DidStr{被除数串}:string;const DivStr{除数串}:string;
var QuotientStr{商数串},RemainderStr{累计余数串}:string);
const
MAX_Value=4294967295 div 10 -1;
var
DividendSect,Divisor,
QuotientInt,RemainderInt,
I :Integer;
PDid
Char;
begin
Divisor:=StrToInt(DivStr);
if (DiviSor=0) or(DidStr='') then
Abort;
DividendSect:=0;
PDid:=PChar(DidStr);
QuotientStr:='';
while PDid^<>''do begin
while (DividendSect<=MAX_Value)and(PDid^<>'')do
begin
DividendSect:=DividendSect*10+Ord(PDid^)-Ord('0');
Inc(PDid);
end;
asm
MOV EAX,DividendSect
XOR EDX,EDX
MOV ECX,Divisor
DIV ECX
MOV QuotientInt,EAX
MOV RemainderInt,EDX
MOV DividendSect,EDX
end;
if (QuotientInt<>0) or (QuotientStr<>'') then
QuotientStr:=QuotientStr+IntToStr(QuotientInt);
end;
RemainderStr:=RemainderStr+IntToStr(RemainderInt);
end;
var
QuotientStr{商数串}:string;
begin
GetRemainderStr(DidStr,DivStr,QuotientStr,Result);
while QuotientStr<>''do
begin
GetRemainderStr(QuotientStr,DivStr,QuotientStr,Result);
end;
end;