discretize(floor)

koadrobot/aritmatics/discretize(floor)

If input `X` is between the threshold `T0`, `T1`, ..., `T𝑛` then output is the UPPER threshold. If `X` is even greater than the last threshold, the value is round down to it.
discretize(floor)
@/discretize(floor)
If input `X` is between the threshold `T0`, `T1`, ..., `T𝑛` then output is the UPPER threshold. If `X` is even greater than the last threshold, the value is round down to it.
Xnumber
Input Value that will be discretize.
T0number
T1number (variadic)
discretize(floor)
X
T0
T1
T
Tnumber
The rounding result. Equals to one of Tx.
To use the node in your project you should have the koadrobot/aritmatics 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) {
    auto x = getValue<input_X>(ctx);
    auto t0 = getValue<input_T0>(ctx);
    auto t1 = getValue<input_T1>(ctx);
    emitValue<output_T>(ctx, (x > t0) ? t1 : t0);
}

Tabular tests

XT0T1T
1131
2133
3133
0131
4133