DelphiBasics
Max
Function
Gives the maximum of two integer values Math unit
 function Max ( const A, B : Integer|Int64|Single|Double|Extended ) : Integer|Int64|Single|Double|Extended;
Description
The Max function returns the value of higher 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
Mean Gives the average for a set of numbers
Min Gives the minimum of two integer values
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 Max
var
  int1, int2, int3 : Integer;
begin
  int1 := 37;
  int2 := 38;
  int3 := Max(int1, int2);

  ShowMessage('int1 = '+IntToStr(int1));
  ShowMessage('int2 = '+IntToStr(int2));
  ShowMessage('Max(int1, int2) = '+IntToStr(int3));
end;
Show full unit code
   int1 = 37
   int2 = 38
   Max(int1, int2) = 38
 
Example code : Illustrating Max of mixed number types
var
  int1   : Integer;
  float1 : single;
begin
  int1   := 37;
  float1 := 37.5;
  float1 := Max(float1, int1);
  ShowMessage('Max(float1, int1) = '+FloatToStr(float1));
end;
Show full unit code
   Max(float1, int1) = 37.5
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Home Page