beetlebug▾
/

tcl::mathfunc min

Gives the smallest of one or more numbers.

tcl::mathfunc::min NUMBER ?NUMBER ...?
expr {min(NUMBER, ?NUMBER, ...?)}

Description

Compares the arguments as numbers and gives the smallest one as it is: an integer stays an integer and a float stays a float. Of two equal arguments the first one is the result, so min(1.0, 1) is 1.0. NaN is an error.

Arguments

ArgumentTypeDefaultDescription
NUMBERnumberrequiredA number.

Returns

One of the arguments.

Examples

% expr {min(3, 9, 4)}
3

% expr {min(1.0, 1)}
1.0

Errors

% expr {min()}
not enough arguments to math function "min"
-errorcode NONE

# Tcl 9.1 only
% expr {min(NaN, 1)}
cannot use non-numeric floating-point value "NaN" as operand of "min"
-errorcode ARITH DOMAIN {non-numeric floating-point value}

# Tcl 8.6 only
% expr {min(NaN, 1)}
can't use non-numeric floating-point value as operand of "min"
-errorcode ARITH DOMAIN {non-numeric floating-point value}

Facts

Capability
None.
Tcl release
Tcl 9.1 and 8.6.
Since
ztcl 1.0.0-beta.1

See also