MIN

Contents


min is used to find the minimum from a series of numerical, alphanumeric or date variables.

 

Syntax

   min( list_exprg )

 

Parameters

Element

Description

Comments

list_exprg

List of expressions_généralisées separated by ','.

All expressions must be the same type.

 

Examples

   # Minimum of several numerical expressions
   # This programme displays 0.01
    MINIMUM = min( pi, exp(1), log(24), sqr(2)*2, sin(0.58), 5*sqr(3))
    MINIMUM = ar2(MINIMUM)
    Infbox num$(MINIMUM)
   # Minimum of several strings
    Char MOTS(40)(50)   :# Definition of 50 variables of 40 characters
    Gosub LIRE_MOTS   :# This sub-programme completes the variables
    PREMIER_MOT = min(MOTS)
   # Check that none of the dates is earlier than DEB_PERIODE; the dates
   # have been entered in a scrolling table whose bottom of
   # table variable is VARBAS
     If min([M]DATES(0..[M]VARBAS-1) < DEB_PERIODE
      Errbox "Date outside range!"
    Endif

 

Description and comments

min is used to calculate the overall minimum of any number of variables or expressions of the same type (alphanumeric, date or numerical).

For a numerical minimum, Integer, Text, Decimal and Shortint type expressions and variables may be mixed. For an alphanumeric minimum, comparison is made along the line of the strings.

The type of result depends on the type of the arguments, that is:

·         minimum strings:      the result is a Char type,

·         minimum of dates:    the result is a Date type,

·         minimum numerical:  the result is Integer or Decimal depending on the type of the minimum value.

If one of the arguments in the function is a dimensioned variable without specifying index or range of indices all the variable elements are used. The index or range of indices specified determines the elements to be considered.

If a range of indices is given, such that there is no element for example min(VARIABLE(1..0)), the result returned is the largest value depending on the type of variable, being respectively string$(255,255) for strings, 255 for text, 2^15-1 for short integers, 2^31-1 for long integers, about 10^80 for decimals and doubles, about 10^38 for floating point, [31/12/9999] for dates.

 

Associated errors

Error

Description

ERMODE (10)

The indices given are not numerical.

ERINDI ( 8)

Error in limits for indices.

ERDOM (50)

The arguments are not of the same type.

ERDIM (55)

Too many dimensions given.

 

Associated key words

MAX - SUM - PRD - AVG - VAR - UNI - FIND


CONTENTS


Copyright © Sage 1999 - 2007