[Overview][Constants][Types][Classes][Procedures and functions] Reference for unit 'math' (#rtl)

minvalue

Return smallest value in array

Declaration

Source position: line 0

function minvalue(

  const data: array [] of float

):float;

function minvalue(

  const data: array [] of Integer

):Integer;

function minvalue(

  const data: PFloat;

  const N: Integer

):float;

function MinValue(

  const Data: PInteger;

  const N: Integer

):Integer;

Description

Minvalue returns the smallest value in the data array with integer or float values. The return value has the same type as the elements of the array.

The third and fourth forms accept a pointer to an array of N integer or float values.

Errors

None.

See also

maxIntValue

  

Return largest element in integer array

maxvalue

  

Return largest value in array

minIntValue

  

Return smallest value in integer array

Example

Program Example26;

{ Program to demonstrate the MinValue function. }

{ Make sore integer is 32 bit}
{$mode objfpc}

Uses math;

Type
  TExFloatArray = Array[1..100] of Float;
  TExIntArray = Array[1..100] of Integer;

Var
  I : Integer;
  ExFloatArray : TExFloatArray;
  AFloatArray : PFloat;
  ExIntArray : TExIntArray;
  AintArray : PInteger;

begin
  Randomize;
  AFloatArray:=@ExFloatArray[0];
  AIntArray:=@ExIntArray[0];
  for I:=1 to 100 do
    ExFloatArray[i]:=(Random-Random)*100;
  for I:=1 to 100 do
    ExIntArray[i]:=Random(I)-Random(100);
  Writeln('Min Float       : ',MinValue(ExFloatArray):8:4);
  Writeln('Min Float   (b) : ',MinValue(AFloatArray,100):8:4);
  Writeln('Min Integer     : ',MinValue(ExIntArray):8);
  Writeln('Min Integer (b) : ',MinValue(AintArray,100):8);
end.