Home > Math > How to Get the Smallest Number From an Array

How to Get the Smallest Number From an Array

December 15th, 1999 m3Rlin Leave a comment Go to comments

The idea is the same as in tip 6.1 but this functions finds the smallest number.

{ You can easily modify this function to accept other numerical types }
function MinInteger(const aInt: array of Integer): Integer;
var
  iI: Integer;
begin
  Result := aInt[Low(aInt)];
  for iI := Low(aInt) + 1 to High(aInt) do
    if aInt[iI] < Result then
      Result := aInt[iI];
end;
  1. No comments yet.