DelphiBasics
Min
Function
Gives the minimum of two integer values Math unit
 function Min ( const A, B : Integer|Int64|Single|Double|Extended ) : Integer|Int64|Single|Double|Extended;
Description
The Min function returns the value of lower of two numeric arguments, A and B.
 
These arguments may be any of the given numeric types, in any mixture. The result will be normalised to the appropriate value - floating point if either argument is floating point.
Related commands
Max Gives the maximum of two integer values
Mean Gives the average for a set of numbers
CompareValue Compare numeric values with a tolerance
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 Download this web site as a Windows program.




 
Example code : Illustrate integer use of Min
var
  int1, int2, int3 : Integer;
begin
  int1 := 37;
  int2 := 38;
  int3 := Min(int1, int2);

  ShowMessage('int1 = '+IntToStr(int1));
  ShowMessage('int2 = '+IntToStr(int2));
  ShowMessage('Min(int1, int2) = '+IntToStr(int3));
end;
Show full unit code
   int1 = 37
   int2 = 38
   Min(int1, int2) = 37
 
Example code : Illustrating Min of mixed number types
// Full Unit code.
// -----------------------------------------------------------
// You must store this code in a unit called Unit1 with a form
// called Form1 that has an OnCreate event called FormCreate.
 
unit Unit1;
 
interface
 
uses
  Math,   // Unit containing the Min command
  SysUtils,
  Forms, Dialogs;
 
type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  end;
 
var
  
Form1: TForm1;
 
implementation
{$R *.dfm} // Include form definitions
 
procedure TForm1.FormCreate(Sender: TObject);

var
  int1   : Integer;
  float1 : single;
begin
  int1   := 38;
  float1 := 37.5;
  float1 := Min(float1, int1);
  ShowMessage('Min(float1, int1) = '+FloatToStr(float1));
end;
 
end.
Hide full unit code
   Min(float1, int1) = 37.5
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Home Page