Skip to content

Float Math Operation

Performs basic mathematical operations on floating-point values. Supports addition, subtraction, multiplication, division, modulo, power, square root, and absolute value. Includes safety checks for division/modulo by zero and square root of negative numbers, returning 0.0 in those cases.
Preview

Usage

Use this node when you need to compute a single float result from two float inputs in a workflow (e.g., scaling, normalizing, combining values). Connect float outputs from prior nodes to inputs a and b, then choose the desired operation. For sqrt and abs, only input a is used.

Inputs

FieldRequiredTypeDescriptionExample
aTrueFLOATFirst float operand. Used as the primary input for all operations and the sole input for sqrt and abs.3.5
bTrueFLOATSecond float operand. Used for binary operations (add, subtract, multiply, divide, modulo, power). Ignored for sqrt and abs.2.0
operationTrueSELECTMathematical operation to apply. Options: add (a + b), subtract (a - b), multiply (a * b), divide (a / b), modulo (a % b), power (a ** b), sqrt (sqrt(a)), abs (abs(a)).divide

Outputs

FieldTypeDescriptionExample
resultFLOATThe computed float result for the selected operation. Returns 0.0 if an invalid operation occurs (e.g., division by zero, modulo by zero, sqrt of a negative).1.75

Important Notes

  • Operation scope: sqrt and abs only use input a; input b is ignored for these.
  • Division/modulo by zero: If b is 0 for divide or modulo, the node returns 0.0 and logs a warning.
  • Square root domain: If a is negative for sqrt, the node returns 0.0 and logs a warning.
  • Input ranges: a and b accept values in [-1e10, 1e10] with a step of 0.001.
  • Precision/tolerance: Results are standard Python float computations; consider floating-point precision implications for equality or modulo.
  • Power operation: Large exponents or certain combinations may overflow or produce infinities/NaN depending on inputs.

Troubleshooting

  • Result is 0.0 unexpectedly: Check if you performed divide/modulo by zero or sqrt on a negative number; the node returns 0.0 in these cases.
  • Unexpected result for sqrt/abs: Ensure you supplied the intended value to a; b is ignored for these operations.
  • Inaccurate decimal results: Floating-point arithmetic can introduce rounding errors. If exactness is required, consider scaling or alternative numeric handling before/after this node.
  • Overflow or inf results with power: Reduce magnitude of a or b to avoid overflow, or clamp values upstream.
  • Modulo behavior with floats: Floating-point modulo follows Python semantics and may be sensitive to precision; consider rounding inputs if needed.