Skip to content

Math Operations

Math Operations

  • ADD <variable_1> AND <variable_2> TO <new_variable>: Add two numbers.
  • SUBTRACT <variable_1> FROM <variable_2> TO <new_variable>: Subtract one number from another.
  • ... Other operations like MULTIPLY, DIVIDE, etc.

Example - Math Operations

  1. Adding Numbers: Let's say you have two variables, var1 with the value 5 and var2 with the value 3. You want to add them.

    ADD var1 AND var2 TO result
    
    After executing the above, the result variable will have the value 8.

  2. Subtracting Numbers: Consider a variable num1 with the value 10 and another variable num2 with the value 4. You want to subtract num2 from num1.

    SUBTRACT num2 FROM num1 TO difference
    
    After this operation, the difference variable will have the value 6.

  3. Multiplying Numbers: If you have two variables, factor1 with the value 7 and factor2 with the value 6, and you want to multiply them.

    MULTIPLY factor1 AND factor2 TO product
    
    The product variable will now hold the value 42.

  4. Dividing Numbers: Consider you have a variable dividend with the value 48 and another variable divisor with the value 6. You want to divide dividend by divisor.

    DIVIDE dividend BY divisor TO quotient
    
    After executing this, the quotient variable will have the value 8.

FAQ - Math Operations

What types of math operations are supported by Flux?

Flux supports basic math operations such as addition, subtraction, multiplication, and division.

Can I perform math operations on variables?

Yes, you can perform math operations on variables. For example, you can use the ADD command to add two variables.

Is it possible to perform math operations on the result of a previous operation?

Yes, you can perform math operations on the result of a previous operation. For example, you can add a number to the result of a subtraction operation.

Can I perform math operations on numbers received from MQTT topics?

Yes, you can perform math operations on numbers received from MQTT topics.

Are there any limitations on the numbers I can use in math operations?

Flux is designed for IoT environments and is not intended for heavy computational tasks. It is recommended to use it for simple calculations. Always consult platform limits.

Can I use floating-point numbers in math operations?

Yes, you can use floating-point numbers in math operations.