# Math::Average
Math::Average
I1
I2
I3
I4
O
# Eingänge
| ID | Kürzel | Name | Typ | Standard | Beschreibung |
|---|---|---|---|---|---|
input_1 | I1 | input_1 | NUMBER | -9223372036854775807 | |
input_2 | I2 | input_2 | NUMBER | -9223372036854775807 | |
input_3 | I3 | input_3 | NUMBER | -9223372036854775807 | |
input_4 | I4 | input_4 | NUMBER | -9223372036854775807 |
# Ausgänge
| ID | Kürzel | Name | Typ | Standard | Beschreibung |
|---|---|---|---|---|---|
output | O | output | NUMBER | 0 |
# Quellcode
Volang-Quellcode anzeigen
i = 1
sum = 0.0
divider = 0
while (i<=4) {
input = input::get(str::fmt("input_{}", i))
// check if input was provided any value by comparing to a default value of min(i64)
hasValue = input != -9223372036854775807
if (hasValue) {
sum += input
divider += 1
}
i += 1
}
fn round2decimal(value) {
return math::round(100.0 * value) / 100.0
}
if (divider == 0) {
output::set("output", 0)
} else {
output::set("output", round2decimal(sum / divider))
}
