Pi/de
Deutsch · English · Français · Suomi · Русский · 中文(中国)
π ist das Verhältnis des Umfangs eines Kreises zu seinem Durchmesser.
Der Wert von π ist in etwa 3,14159265358979.
Der Umfang eines Kreises wird enweder mit
U = π (2 * r)
oder mit
U = π * d
berechnet.\
In Pascal ist pi eine Funktion, die den Wert von π zurückgibt.\
π/4 ist das gleiche wie arctan(1).\
Sämtliche Trigonometrische Funktionen (sin, cos, etc.) werden mit FPC im Bogenmass berechnet. Dies entspricht 360° = 2 * Pi.\
Olaf 20:06, 20 November 2016 (CET)
Pi hoch aufgelöst
Will man Pi sehr genau ausrechnen, kann man sich mit folgender Procedure behelfen.
program Project1;
uses
Crt;
var
stellen: integer;
procedure CalcPi;
var
r, p: string;
m, i, j, u, z: integer;
c: array of integer;
begin
SetLength(c, 10 * (Stellen + 1) div 3 + 1);
r := '';
p := '';
m := 10 * (Stellen + 1) div 3;
for i := 1 to m do begin
c[i] := 2;
end;
for j := 0 to Stellen do begin
if j mod 100 = 0 then begin
GotoXY(1, 1);
WriteLn('Stelle: ', j);
end;
u := 0;
for i := m downto 2 do begin
z := 10 * c[i] + u;
c[i] := z mod (i * 2 - 1);
u := z div (i * 2 - 1) * (i - 1);
end;
z := 10 * c[1] + u;
c[1] := z mod 10;
u := z div 10;
if u <= 8 then begin
r := r + p;
p := Chr(48 + u);
end;
if u = 9 then begin
p := p + Chr(48 + u);
end;
if u = 10 then begin
for i := 1 to Length(p) do begin
Val(p[i], z, u);
Inc(z);
if z = 10 then begin
z := 0;
end;
p[i] := Chr(48 + z);
end;
p := p + '0';
end;
end;
p := r[1] + '.' + Copy(r, 2, Length(r)) + p;
WriteLn(p);
SetLength(c, 0);
end;
begin
ClrScr;
Writeln('Bitte Stellen eingeben: ');
readln(stellen);
CalcPi;
end.From the Free Pascal wiki, page "Pi/de", as it stood on 2018-02-11 after a change by Mathias, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.
Talk about this page
Nobody has opened a bench for this page yet. Sign in to open one.
