Skip to content

Int Math Operation

Performs a basic mathematical operation on two integers. Supports addition, subtraction, multiplication, integer division, modulo, and exponentiation. Handles divide/modulo by zero by returning 0 and logging a warning.
Preview

Usage

Use this node whenever you need simple arithmetic between two integer values in a workflow. Typical uses include counters, index calculations, loop arithmetic, and conditional evaluations where integer results are required.

Inputs

FieldRequiredTypeDescriptionExample
aTrueINTFirst integer operand. Supports very large positive or negative integers.10
bTrueINTSecond integer operand. Supports very large positive or negative integers.3
operationTrueENUMThe arithmetic operation to apply to a and b. Options: add, subtract, multiply, divide (integer division), modulo, power.divide

Outputs

FieldTypeDescriptionExample
resultINTThe integer result of the selected operation. For divide, the result is integer (floor) division.3

Important Notes

  • Division is integer division using floor semantics; results with negative numbers are floored, not truncated toward zero.
  • Divide and modulo by zero are guarded; the node returns 0 and logs a warning in these cases.
  • If an unknown operation is provided, the node returns 0 and logs a warning.
  • Exponentiation can produce very large numbers; extremely large exponents may be slow or resource-intensive.
  • Using a negative exponent will mathematically yield a fractional result in Python, but the node declares an INT output; avoid negative exponents to keep results integral.
  • Valid operations are exactly: add, subtract, multiply, divide, modulo, power.

Troubleshooting

  • Result is 0 unexpectedly: Check for divide/modulo by zero or an invalid operation string; both return 0 by design.
  • Unexpected negative division result: Remember the node uses floor division; for negative operands, the quotient is floored (e.g., -3 // 2 = -2).
  • Large or slow computation: Very large exponents can be expensive; reduce the exponent or reconsider the operation.
  • Non-integer-like output expected from power: Avoid negative exponents; use non-negative integer exponents to keep the output integral.
  • Operation not found in the dropdown: Ensure the operation is one of add, subtract, multiply, divide, modulo, power.