min, max Functions on Numerals

Prev Next

Function Names

min 123, max 123, min 123 ignore zero, max 124 ignore zero, min numeral, max numeral, min numeral ignore zero, max numeral ignore zero

Description

These functions identify the minimum or maximum numeric values. Following rules apply

  • The suffix ... ignore zero ignores all 0 (zero) values in the comparison process. If all parameters contain 0, then 0 is returned.
  • Function names containing numeral require the parameters to be of type numeral. Otherwise exceptions happen.
  • Function names containing abc will convert the parameters into numerals before comparing them, e.g. "0123" converts to "123". Strings not containing numbers will be treated as zero which you may want to ignore.

Minimum Function Name Maximum Function Name Autom. Type conversion Description
min 123 max 123 Yes Picks minimum or maximum numeric value provided
min numeral max numeral No "
min 123 ignore zero max 123 ignore zero Yes Picks minimum or maximum numeric value provided, but 0's are ignored
min numeral ignore zero max string ignore zero No "

Please note that equivalent conditional combination functions are also available for the function names listed above which allows you to pre-select specific parameters to include in the calculation using one or more comparisons .

Call as: function

Parameter count

Min 1

Parameters

No.TypeDescription
1, etc.
input
valid types All function parameters:

Same parameter passing principle is applied like other series functions such as add(), sub(), etc.
See Two parameter passing methods for series functions for details..

Return value

TypeDescription
numeral Result

Calculated value

Exceptions

Function names containing 'numeral' assert exceptions if values provided are not of type numeral.

Examples

               echo( max 123( 1, 3, 5 ) ); // 5
               echo( min 123( "0002", "1", "3" ) ); // 1
               echo( max 123 ignore zero( -4, -2, 0, -1 ) ); // -1

Output

5
1
-1
Try it yourself: Open LIB_Function_min_123.b4p in B4P_Examples.zip. Decompress before use.

See also

min abc
max abc
min string
max string
min
max