Skip to content

Advanced Math Operation

Performs a set of advanced mathematical operations on a single number, with optional use of a second integer for GCD/LCM. Supported operations include absolute value, square root, cube root, factorial (of the integer part), greatest common divisor, and least common multiple.
Preview

Usage

Use this node when you need single-input advanced math utilities or integer-based pair operations (GCD/LCM). Typical workflow: feed a numeric value, choose the operation, and provide the secondary integer only when using GCD or LCM. The node returns the result as a float.

Inputs

FieldRequiredTypeDescriptionExample
valueTrueFLOATPrimary numeric input. Used by all operations. For factorial/GCD/LCM, its absolute integer part is used internally.16.0
operationTrue["abs", "sqrt", "cbrt", "factorial", "gcd", "lcm"]Selects the operation to perform.sqrt
second_valueTrueINTSecondary integer used only for GCD and LCM. Ignored for other operations.12

Outputs

FieldTypeDescriptionExample
resultFLOATThe computed result of the selected operation.4.0

Important Notes

  • Absolute value (abs): Returns the absolute value of 'value'.
  • Square root (sqrt): Requires value >= 0. If value is negative, the node returns 0.0.
  • Cube root (cbrt): Only supports non-negative inputs; negative inputs will result in 0.0.
  • Factorial: Uses the absolute integer part of 'value' (floor of abs(value)). Values that would produce excessively large factorials (greater than 170!) return 0.0.
  • GCD/LCM: Both operate on the absolute integer parts of 'value' and 'second_value'.
  • LCM with zero: If the integer part of 'value' is 0, the LCM result is 0.
  • Output type: Results are returned as FLOAT, even when the underlying operation is integer-based (factorial, gcd, lcm).
  • Second value range: 'second_value' is constrained to integers between 1 and 1000.

Troubleshooting

  • Got 0.0 unexpectedly: Check for invalid inputs: negative values for sqrt or cbrt, factorial too large (>170!), or other input constraints.
  • GCD/LCM results seem off: Remember the node uses the absolute integer parts of inputs. Verify 'value' and 'second_value' after conversion to integers.
  • LCM returned 0: This occurs if the integer part of 'value' is 0.
  • Need cube root of a negative number: This node does not support negative cube roots; use a method that handles signed cube roots.