Skip to content

Advanced Math Operation

Performs a set of advanced mathematical operations on a single value, with optional use of a second integer for number-theoretic functions. Supports absolute value, square root, cube root, factorial (of the integer part), greatest common divisor (GCD), and least common multiple (LCM). Returns the computed result as a float and safeguards against invalid inputs.
Preview

Usage

Use this node when you need single-operand advanced math or integer number theory operations within a workflow. Typical patterns include: cleaning values via abs, deriving magnitudes with sqrt/cbrt, computing factorials for integer counts, or combining an input with a second integer using gcd/lcm. For gcd and lcm, supply the second_value; for other operations it is ignored.

Inputs

FieldRequiredTypeDescriptionExample
valueTrueFLOATPrimary numeric input used by all operations. Interpreted as a real number; for integer-specific operations (factorial, gcd, lcm) its integer part is used.16.0
operationTrueCHOICESelect the operation to perform: abs, sqrt, cbrt, factorial, gcd, or lcm. For gcd/lcm, second_value is required.sqrt
second_valueTrueINTSecondary integer used only for gcd and lcm operations. Ignored for abs, sqrt, cbrt, and factorial.12

Outputs

FieldTypeDescriptionExample
resultFLOATThe computed result of the selected operation. Integer results (e.g., from gcd/lcm/factorial) are returned as floats.4.0

Important Notes

  • Operation behaviors: abs returns |value|; sqrt returns the square root (requires value >= 0); cbrt returns the cube root; factorial uses the integer part of |value|; gcd/lcm use the integer parts of |value| and |second_value|.
  • Invalid inputs return 0.0: The node returns 0.0 when inputs are invalid (e.g., sqrt of a negative number).
  • Factorial limits: Factorial is computed only up to 170 to prevent overflow; larger inputs yield 0.0.
  • Integer casting for number theory: For factorial, gcd, and lcm, both inputs are converted to non-negative integers by taking their absolute values and integer parts.
  • LCM with zeros: If either integer is 0, lcm returns 0.
  • Cube root edge cases: Cube root is computed via exponentiation. In some environments, negative inputs may not produce a real cube root; if an error occurs, the node returns 0.0.

Troubleshooting

  • Result is 0.0 unexpectedly: Check for invalid input combinations (e.g., negative value for sqrt, factorial beyond 170) or errors from cbrt on negative values.
  • gcd/lcm not as expected: Remember values are converted to integers via absolute value and truncation; decimals are discarded.
  • second_value seemingly ignored: second_value only applies to gcd and lcm; it is not used for abs, sqrt, cbrt, or factorial.
  • Large factorial overflow concerns: If using values above 170, reduce the input or reconsider the approach; the node will cap by returning 0.0.