# Math::Divide
Divides the I1 input block value by the value of I2 input
Math::Divide
I1
I2
O
# Inputs
| ID | Abbrev | Name | Type | Default | Description |
|---|---|---|---|---|---|
input_1 | I1 | Input #1 | NUMBER | 0 | Input #1 |
input_2 | I2 | Input #2 | NUMBER | 1 | Input #2 |
# Outputs
| ID | Abbrev | Name | Type | Default | Description |
|---|---|---|---|---|---|
output | O | Output | NUMBER | 0 | Output |
# Configuration
| ID | Name | Type | Default | Unit | Description |
|---|---|---|---|---|---|
trigger_on_input_1 | Trigger on Input #1 | BOOLEAN | true | When enabled, changes to Input #1 trigger output recalculation | |
trigger_on_input_2 | Trigger on Input #2 | BOOLEAN | true | When enabled, changes to Input #2 trigger output recalculation |
# Source Code
View Volang source
channel = input::channel()
trigger = false
if (channel == "input_1" and config::get("trigger_on_input_1")) {
trigger = true
}
if (channel == "input_2" and config::get("trigger_on_input_2")) {
trigger = true
}
if (!trigger) {
return
}
i1 = input::get("input_1")
i2 = input::get("input_2")
fn round2decimal(value) {
return math::round(100.0 * value) / 100.0
}
if (i2 != 0) {
output::set("output", round2decimal(1.0 * i1 / i2))
} else {
output::set("output", 0)
}
