DelphiDabbler Code Snippets Database

Snippet Selection

The following snippets from the Code Snippets Database have been requested.

MaxOfArray (Double overload)

Returns the maximum value contained in the given array of double precision floating point values. The array must not be empty.

function MaxOfArray(const A: array of Double): Double; overload;
var
  Idx: Integer;
begin
  Assert(Length(A) > 0);
  Result := A[Low(A)];
  for Idx := Succ(Low(A)) to High(A) do
    if A[Idx] > Result then
      Result := A[Idx];
end;

MaxOfArray (Extended overload)

Returns the maximum value contained in the given array of extended precision floating point values. The array must not be empty.

function MaxOfArray(const A: array of Extended): Extended; overload;
var
  Idx: Integer;
begin
  Assert(Length(A) > 0);
  Result := A[Low(A)];
  for Idx := Succ(Low(A)) to High(A) do
    if A[Idx] > Result then
      Result := A[Idx];
end;

MaxOfArray (Int64 overload)

Returns the maximum value contained in the given array of 64 bit integer values. The array must not be empty.

function MaxOfArray(const A: array of Int64): Int64; overload;
var
  Idx: Integer;
begin
  Assert(Length(A) > 0);
  Result := A[Low(A)];
  for Idx := Succ(Low(A)) to High(A) do
    if A[Idx] > Result then
      Result := A[Idx];
end;

MaxOfArray (Integer overload)

Returns the maximum value contained in the given array of integer values. The array must not be empty.

function MaxOfArray(const A: array of Integer): Integer; overload;
var
  Idx: Integer;
begin
  Assert(Length(A) > 0);
  Result := A[Low(A)];
  for Idx := Succ(Low(A)) to High(A) do
    if A[Idx] > Result then
      Result := A[Idx];
end;

MaxOfArray (Single overload)

Returns the maximum value contained in the given array of single precision floating point values. The array must not be empty.

function MaxOfArray(const A: array of Single): Single; overload;
var
  Idx: Integer;
begin
  Assert(Length(A) > 0);
  Result := A[Low(A)];
  for Idx := Succ(Low(A)) to High(A) do
    if A[Idx] > Result then
      Result := A[Idx];
end;

Mid (Double overload)

Returns the middle of three double precision floating point values.

function Mid(const A, B, C: Double): Double; overload;
begin
  Result := Math.Min(
    Math.Min(
      Math.Max(A, B), Math.Max(B, C)
    ),
    Math.Max(A, C)
  );
end;

Mid (Extended overload)

Returns the middle of three extended precision floating point values.

function Mid(const A, B, C: Extended): Extended; overload;
begin
  Result := Math.Min(
    Math.Min(
      Math.Max(A, B), Math.Max(B, C)
    ),
    Math.Max(A, C)
  );
end;

Mid (Int64 overload)

Returns the middle of three 64 bit integer values.

function Mid(const A, B, C: Int64): Int64; overload;
begin
  Result := Math.Min(
    Math.Min(
      Math.Max(A, B), Math.Max(B, C)
    ),
    Math.Max(A, C)
  );
end;

Mid (Integer overload)

Returns the middle of three integer values.

function Mid(const A, B, C: Integer): Integer; overload;
begin
  Result := Math.Min(
    Math.Min(
      Math.Max(A, B), Math.Max(B, C)
    ),
    Math.Max(A, C)
  );
end;

Mid (Single overload)

Returns the middle of three single precision floating point values.

function Mid(const A, B, C: Single): Single; overload;
begin
  Result := Math.Min(
    Math.Min(
      Math.Max(A, B), Math.Max(B, C)
    ),
    Math.Max(A, C)
  );
end;

MinOfArray (Double overload)

Returns the minimum value contained in the given array of double precision floating point values. The array must not be empty.

function MinOfArray(const A: array of Double): Double; overload;
var
  Idx: Integer;
begin
  Assert(Length(A) > 0);
  Result := A[Low(A)];
  for Idx := Succ(Low(A)) to High(A) do
    if A[Idx] < Result then
      Result := A[Idx];
end;

MinOfArray (Extended overload)

Returns the minimum value contained in the given array of extended precision floating point values. The array must not be empty.

function MinOfArray(const A: array of Extended): Extended; overload;
var
  Idx: Integer;
begin
  Assert(Length(A) > 0);
  Result := A[Low(A)];
  for Idx := Succ(Low(A)) to High(A) do
    if A[Idx] < Result then
      Result := A[Idx];
end;

MinOfArray (Int64 overload)

Returns the minimum value contained in the given array of 64 bit integer values. The array must not be empty.

function MinOfArray(const A: array of Int64): Int64; overload;
var
  Idx: Integer;
begin
  Assert(Length(A) > 0);
  Result := A[Low(A)];
  for Idx := Succ(Low(A)) to High(A) do
    if A[Idx] < Result then
      Result := A[Idx];
end;

MinOfArray (Integer overload)

Returns the minimum value contained in the given array of integer values. The array must not be empty.

function MinOfArray(const A: array of Integer): Integer; overload;
var
  Idx: Integer;
begin
  Assert(Length(A) > 0);
  Result := A[Low(A)];
  for Idx := Succ(Low(A)) to High(A) do
    if A[Idx] < Result then
      Result := A[Idx];
end;

MinOfArray (Single overload)

Returns the minimum value contained in the given array of single precision floating point values. The array must not be empty.

function MinOfArray(const A: array of Single): Single; overload;
var
  Idx: Integer;
begin
  Assert(Length(A) > 0);
  Result := A[Low(A)];
  for Idx := Succ(Low(A)) to High(A) do
    if A[Idx] < Result then
      Result := A[Idx];
end;

View the whole database.

Go to the DelphiDabbler website.