Max and Min
- Updated2023-02-17
- 3 minute(s) read
Max and Min
Compares two values and returns the maximum and minimum values.

Inputs/Outputs

x
The value to compare.
Data Type Changes on FPGA
When you add this node to a document targeted to an FPGA, this input has a default data type that uses fewer hardware resources at compile time.

y
The value to compare.
Data Type Changes on FPGA
When you add this node to a document targeted to an FPGA, this input has a default data type that uses fewer hardware resources at compile time.

max
The larger value.
Data Type Changes on FPGA
When you add this node to a document targeted to an FPGA, this output has a default data type that uses fewer hardware resources at compile time.

min
The smaller value.
Data Type Changes on FPGA
When you add this node to a document targeted to an FPGA, this output has a default data type that uses fewer hardware resources at compile time.
Examples
Parameters | Compare Elements | Comments | Compare Aggregates | Comments |
---|---|---|---|---|
First input array (x) | [3,2,3,4] | [3,2,3,4] | ||
Second input array (y) | [2,3,4,5] | [2,3,4,5] | ||
Maximum (max) | [3,3,4,5] | The node returns an array of the maximum elements from the two input arrays. | [3,2,3,4] | Because the first elements of the two input arrays are not equal, and because 3>2, the node stops and returns [3,2,3,4] as the maximum array. |
Minimum (min) | [2,2,3,4] | The node returns an array of the minimum elements from the two input arrays. | [2,3,4,5] | Because the first elements of the two input arrays are not equal, and because 2<3, the node stops and returns [2,3,4,5] as the minimum array. |
Timestamps
This node accepts timestamp values if all inputs are timestamp values. If the inputs are timestamp values, the function returns the later time at the top and the earlier time at the bottom. You can change the comparison mode of this node.
Behavior When Comparing NaN Elements
In Compare Elements mode, when one or both inputs are NaN (Not-a-Number), this function produces the following results:
- Both inputs are NaN-Both max and min return NaN
- Only one input is NaN-Both max and min return the non-NaN value
- Inputs are arrays—The node evaluates each pair of elements according to the previous rules
In Compare Aggregates mode, when one or both inputs are NaN (Not-a-Number), this function produces the following results:
- Both inputs are NaN-Both max and min return NaN
- Only one input is NaN-max returns x and min returns y
- Inputs are arrays—If the node encounters a NaN element in either input array, max returns x and min returns y
Behavior with Array and Cluster Inputs
When using Max and Min to compare arrays and clusters, you can select a comparison mode. Note that Max and Min produces a different type of output than other Comparison nodes in each of the two comparison modes. In Compare Elements mode,Max and Min returns an array or cluster of the maximum elements and minimum elements. In Compare Aggregates mode,Max and Min returns the maximum and minimum array and cluster.