procedure TForm1.W3Button21Click(Sender: TObject);
var
v : Double;
int1, int2, int3 : Integer;
number, squared : Integer;
num, squareRoot : Extended;
begin
// Calculate the exponent of 2
// Get the natural logarithm of 2
v := Ln(2);
// Show this value
WriteLn('Ln(2) = '+FloatToStr(v));
// Get the exponent of this value - reverses the Ln operation
v := Exp(v);
// Show this value
WriteLn('Exp(Ln(2)) = '+FloatToStr(v));
WriteLn('==========');
// Get the natural logarithm of 2
v := Ln(2);
// Show this value
WriteLn('Ln(2) = '+FloatToStr(v));
// Get the exponent of this value - reverses the Ln operation
v := Exp(v);
// Show this value
WriteLn('Exp(Ln(2)) = '+FloatToStr(v));
WriteLn('==========');
// Show the Log to base 10 values of 3 numbers
WriteLn('Log10(1) = '+FloatToStr(Log10(1)));
WriteLn('Log10(5) = '+FloatToStr(Log10(5)));
WriteLn('Log10(10) = '+FloatToStr(Log10(10)));
WriteLn('==========');
// Example code : Illustrate integer use of Max
int1 := 37;
int2 := 38;
int3 := Max(int1, int2);
WriteLn('int1 = '+IntToStr(int1));
WriteLn('int2 = '+IntToStr(int2));
WriteLn('Max(int1, int2) = '+IntToStr(int3));
WriteLn('==========');
//Illustrating Max of mixed number types
int1 := 37;
v := 37.5;
v := Max(v, int1);
WriteLn('Max(v, int1) = '+FloatToStr(v));
WriteLn('==========');
// Illustrate integer use of Min
int1 := 37;
int2 := 38;
int3 := Min(int1, int2);
WriteLn('int1 = '+IntToStr(int1));
WriteLn('int2 = '+IntToStr(int2));
WriteLn('Min(int1, int2) = '+IntToStr(int3));
WriteLn('==========');
//Illustrating Min of mixed number types
int1 := 38;
v := 37.5;
v := Min(v, int1);
WriteLn('Min(v, int1) = '+FloatToStr(v));
WriteLn('==========');
//Find the square of various values
WriteLn('==========');
// The square of 15 = 225
number := 15;
squared := Sqr(number);
WriteLn(Format('%d squared = %d',[number, squared]));
// The square of 17 = 289
// But result exceeds byte size, so result = 289 MOD 256 = 33
number := 17;
squared := Sqr(number);
WriteLn(Format('%d squared = %d (see code above)',[number, squared]));
// The square of infinity is still infinity
v := Infinity;
v := Sqr(v);
WriteLn(Format('Infinity squared = %f',[v]));
WriteLn('==========');
//Find the square root of various values
// The square root of 225 = 15
number := 225;
squareRoot := Sqrt(number);
WriteLn(Format('Square root of %f = %f',[number, squareRoot]));
// The square root of 3.456 = 1.859...
num := 3.456;
squareRoot := Sqrt(num);
WriteLn(Format('Square root of %7.3f = %12.12f',[num, squareRoot]));
// The square root of infinity is still infinity
num := Infinity;
num := Sqrt(num);
WriteLn(Format('Square root of Infinity = %f',[num]));
end;
|