Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Mathe Unit (https://www.delphipraxis.net/4760-mathe-unit.html)

ssach 11. Mai 2003 02:26


Mathe Unit
 
Liste der Anhänge anzeigen (Anzahl: 1)
hy,

ichhabe eine kleine sammlung von mathefunktionen in eineunit geschrieben, wenn ihr vorschlaege habt fuer weitere funtionen, bitte sendet sie mir!!

danke

cu

mirage228 11. Mai 2003 06:12

sind die funktionsnamen und kommentare in FRANZÖSISCH oder kommt mir das nur so vor?

toms 11. Mai 2003 07:59

Hi,

Einige Funktionen gibt's bereits in der Math unit, daher überflüssig.
PS: Der Source Code ist schlecht formatiert.

Sieht doch besser so aus?

Code:
unit Mathe;

interface

uses SysUtils;

implementation

function Factorielle(X: Integer): Longint;
var
  N: Integer;
begin
  Result := 1;
  for N := 1 to X do
    Result := Result * N;
end;

function Exposant(X: real; Y: Integer): Extended;
var
  N: Integer;
  TEMP: real;
begin
  if Y = 0 then
    Result := 1
  else
  begin
    Result := X;
    TEMP  := X;
    for N := 2 to Y do
      Result := Result * TEMP;
    if Y < 0 then
      Result := 1 / Result;
  end;
end;

function Tan(COS: real; SIN: real): real;
begin
  Result := COS / SIN;
end;

function Pourcent(X: real; Y: Integer): Extended;
begin
  Result := (X / 100) * Y;
end;

//Pour un triangle de pascal
function COEF_BINOMIAL(P: Integer; Q: Integer): real;
begin
  Result := Factorielle(P) / (Factorielle(Q) * Factorielle(P - Q));
end;

function Pythagore(A: real; B: real): real;
begin
  Result := sqrt(sqr(A) + sqr(B));
end;

function PairImpair(X: Integer): Boolean;
begin
  Result := True;
  if (X mod 2 <> 0) then Result := False;
end;

function Fibunacci(X: Integer): Extended;
var
  I: Integer;
begin
  Result := 1;
  for I := 1 to X do
    Result := Result + X;
end;

function DecToDual(X: Longint): string;
begin
  Result := '';
  while (X <> 0) do
  begin
    Result := Result + IntToStr(X mod 2);
    X := X div 2;
  end;
end;

function DualtoDec(X: string): Longint;
var
  I, COUNTER: Integer;
begin
  Result := 0;
  COUNTER := 0; //for Exposant
  for I := Length(X) downto 1 do
  begin
    Result := Result + round(Exposant(StrToInt(X[I]), COUNTER));
    COUNTER := COUNTER + 1;
  end;
end;

end.

ssach 11. Mai 2003 20:47

ja,

kommentare sind in französisch *g*! nutze normalerweise englisch jedochj manchmal auch französisch!


Alle Zeitangaben in WEZ +1. Es ist jetzt 05:48 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz