max

koadrobot/math/max

Return maximum number value of the inputs.
max
@/max
Return maximum number value of the inputs.
IN1number
IN2number (variadic)
max
IN1
IN2
OUT
OUTnumber
To use the node in your project you should have the koadrobot/math library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

#pragma XOD dirtieness disable

struct State {};

{{ GENERATED_CODE }}

void evaluate(Context ctx) {
    Number lhs = getValue<input_IN1>(ctx);
    Number rhs = getValue<input_IN2>(ctx);
    emitValue<output_OUT>(ctx, ( (lhs < rhs) || isnan(rhs) ) ? rhs : lhs);
}

Tabular tests

IN1IN2OUT
0.10.010.1
-0.50.50.5
50023002300
-20-1-1
Inf100Inf
-Inf100100
// when any of inputs is NaN — return NaN
NaN1NaN
1NaNNaN
NaNInfNaN
InfNaNNaN
NaN-InfNaN
-InfNaNNaN