Mega Code Archive

 
Categories / Delphi / Functions
 

Min - 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 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 var int1 : Integer; float1 : single; begin int1 := 38; float1 := 37.5; float1 := Min(float1, int1); ShowMessage('Min(float1, int1) = '+FloatToStr(float1)); end; Show full unit code Min(float1, int1) = 37.5