MIN

Returns the smaller of two inputs.

Signature

     ┌─────────┐
IN1 ─┤         │
     │   MIN   ├─ OUT
IN2 ─┤         │
     └─────────┘
FUNCTION MIN : ANY
  VAR_INPUT
    IN1 : ANY;
    IN2 : ANY;
  END_VAR
END_FUNCTION

The return type matches the input type. MIN accepts SINT, INT, DINT, LINT, USINT, UINT, UDINT, ULINT, REAL, LREAL. Both inputs must share the same type.

Inputs

Name

Type

Description

IN1

ANY_MAGNITUDE

The first value to compare.

IN2

ANY_MAGNITUDE

The second value to compare.

Outputs

Name

Type

Description

Return value

ANY_MAGNITUDE

The smaller of IN1 and IN2. If both inputs are equal, returns that value. Same type as the inputs.

Description

Returns the smaller of IN1 and IN2. If both inputs are equal, the function returns that value.

Example

result := MIN(10, 20);    (* result = 10 *)
result := MIN(-5, 3);     (* result = -5 *)

See Also

  • MAX — maximum of two values

  • LIMIT — clamp to range

  • SEL — binary selection

References