xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

Min()

Returns the smallerr value of two Numerics or Dates.

Syntax

Min( <nNum1> , <nNum2>  ) --> nSmallerNumber
Min( <dDate1>, <dDate2> ) --> dSMallerDate

Arguments

<nNum1> and <nNum2>
Two numeric values to be compared.
<nDate1> and <nDate2>
Two Date values to be compared.

Return

The function returns the smaller value of the two arguments.

Description

The function compares two numeric or two Date values and returns the smaller value of both. Min() is used to normalize values against a limit. The inverse function is Max().

Info

See also:Max()
Category: Numeric functions , Date and time
Source:rtl\minmax.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example compares elements of two arrays of different
// length. The limit for the loop counter is determined with
// function Min(). Array elements containing same values are
// collected in a result array.

   PROCEDURE Main
      LOCAL aArray1 := {"A", "B", "C", "D" }
      LOCAL aArray2 := {"D", "B", "C" }
      LOCAL aResult := {}
      LOCAL i, imax

      imax := Min( Len( aArray1 ), Len( aArray2 ) )
      FOR i:=1 TO imax
          IF aArray1[i] == aArray2[i]
             AAdd( aResult, aArray1[i] )
          ENDIF
      NEXT

      ? ValToPrg( aResult )   // result: { "B", "C" }
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe