dos_compilers/Borland Turbo Pascal v1/FLOAT.PAS
2024-06-30 14:18:33 -07:00

51 lines
1.1 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

program tf;
procedure phi;
var
prev2, prev1, i, next : integer;
v : real;
begin
writeln( 'should tend towards 1.618033988749...' );
prev1 := 1;
prev2 := 1;
for i := 1 to 21 do begin { integer overflow beyond this }
next := prev1 + prev2;
prev2 := prev1;
prev1 := next;
v := prev1 / prev2;
writeln( ' at ', i, ' iterations: ', v );
end;
end;
var
r, a, b, c : real;
i, x : integer;
begin { tf }
a := 1.1;
b := 2.2;
c := 3.3;
for i := 1 to 10 do begin
a := b * c;
b := a * c;
r := arctan( a );
r := cos( a );
{ r := exp( a ); }
r := frac( a );
if a <= 32727.0 then r := int( a );
r := ln( a );
r := sin( a );
r := sqr( a );
r := sqrt( a );
if a <= 32767.0 then x := round( a );
if a <= 32767.0 then x := trunc( a );
end;
writeln;
writeln( 'a, b, c: ', a, b, c );
phi;
end. { tf }