# Math::Divide

Process

Divides the I1 input block value by the value of I2 input

Math::Divide
I1
I2
O

# Inputs

IDAbbrevNameTypeDefaultDescription
input_1I1Input #1NUMBER0Input #1
input_2I2Input #2NUMBER1Input #2

# Outputs

IDAbbrevNameTypeDefaultDescription
outputOOutputNUMBER0Output

# Configuration

IDNameTypeDefaultUnitDescription
trigger_on_input_1Trigger on Input #1BOOLEANtrueWhen enabled, changes to Input #1 trigger output recalculation
trigger_on_input_2Trigger on Input #2BOOLEANtrueWhen 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)
}
Divides the I1 input block value by the value of I2 input