From 7ac4a3519ae45c851d7c66bf27795722b0d5fe9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20M=C3=BCller?= Date: Mon, 20 May 2024 01:04:18 +0200 Subject: [PATCH] Added TBigIntPolynomial.ToString --- UPolynomial.pas | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/UPolynomial.pas b/UPolynomial.pas index 13528ff..9a4374f 100644 --- a/UPolynomial.pas +++ b/UPolynomial.pas @@ -40,6 +40,7 @@ type function CalcValueAt(const AX: Int64): TBigInt; function IsEqualTo(const AOther: TBigIntPolynomial): Boolean; function ScaleVariable(const AScaleFactor: TBigInt): TBigIntPolynomial; + function ToString: string; class function Create(const ACoefficients: array of TBigInt): TBigIntPolynomial; static; end; @@ -109,6 +110,18 @@ begin SetLength(Result.FCoefficients, 0); end; +function TBigIntPolynomial.ToString: string; +var + i: Integer; +begin + Result := FCoefficients[0].ToString; + for i := 1 to Length(FCoefficients) - 1 do + if i > 1 then + Result := Result + ' + ' + FCoefficients[i].ToString + ' * x^' + IntToStr(i) + else + Result := Result + ' + ' + FCoefficients[i].ToString + ' * x'; +end; + class function TBigIntPolynomial.Create(const ACoefficients: array of TBigInt): TBigIntPolynomial; var high, i: integer;