下面的函数是ehom编写的
function InfiniteSub(mNumberA, mNumberB: string): string;
var
I: Integer;
T: Integer;
TemNumA:String;
minus:Boolean;
begin
Result := '';
if Pos('.', mNumberA) <= 0 then mNumberA := mNumberA + '.';
if Pos('.', mNumberB) <= 0 then mNumberB := mNumberB + '.';
I := Max(Length(StrLeft(mNumberA, '.')), Length(StrLeft(mNumberB, '.')));
mNumberA := DupeString('0', I - Length(StrLeft(mNumberA, '.'))) + mNumberA;
mNumberB := DupeString('0', I - Length(StrLeft(mNumberB, '.'))) + mNumberB;
T := Max(Length(StrRight(mNumberA, '.')), Length(StrRight(mNumberB, '.')));
if ((Length(StrLeft(mNumberA, '.'))) < (Length(StrLeft(mNumberB, '.')))) or(((Length(StrLeft(mNumberA, '.'))) = (Length(StrLeft(mNumberB, '.'))))and(mNumberB<mNumberA))then
begin
TemNumA := mNumberA;
mNumberA := mNumberB + DupeString('0', T - Length(StrRight(mNumberB, '.')));
mNumberB := TemNumA + DupeString('0', T - Length(StrRight(TemNumA, '.')));
minus:=True;
end
else
begin
mNumberA := mNumberA + DupeString('0', T - Length(StrRight(mNumberA, '.')));
mNumberB := mNumberB + DupeString('0', T - Length(StrRight(mNumberB, '.')));
minus:=False;
end;
I := I + T + 1;
T := 0;
for I := I downto 1 do
if [mNumberA[I], mNumberB[I]] <> ['.'] then begin
T := StrToIntDef(mNumberA[I], 0) - T;
T := StrToIntDef(mNumberB[I], 0) - T;
if (T<0) and (I<>1) then
begin
T:=T+10;
Result := IntToStr(T mod 10) + Result;
T := -1;
end
else
begin
Result := IntToStr(T mod 10) + Result;
T := T div 10;
end;
end else Result := '.' + Result;
if T <> 0 then Result := IntToStr(T mod 10) + Result;
while Pos('0', Result) = 1 do Delete(Result, 1, 1);
while Copy(Result, Length(Result), 1) = '0' do
Delete(Result, Length(Result), 1);
if Copy(Result, Length(Result), 1) = '.' then
Delete(Result, Length(Result), 1);
if Copy(Result, 1, 1) = '.' then Result := '0' + Result;
if (Result = '') then Result := '0';
if minus then Result:='-'+Result;
end;