Number Calculator

Realiza operaciones matemáticas simples

Overview

The "Number Calculator" node performs simple mathematical operations on numeric fields within input data items. It supports addition, subtraction, multiplication, division, and squaring of numbers. This node is useful in workflows where you need to compute results based on numeric inputs dynamically, such as calculating totals, differences, or derived values from existing data fields.

For example, you can use this node to:

  • Add two numeric fields like price and tax to get a total amount.
  • Subtract expenses from income to calculate net profit.
  • Multiply quantity by unit price to get total cost.
  • Divide total distance by time to find speed.
  • Calculate the square of a number for statistical or geometric computations.

Properties

Name Meaning
First Number Field The name of the field containing the first number to be used in the operation.
Second Number Field The name of the field containing the second number (not used for the "Square" operation).
Output Field The name of the field where the result of the operation will be stored.

Output

The node outputs an array of items where each item contains the original JSON data plus a new field (as specified by the "Output Field" property) holding the result of the mathematical operation.

Example output structure for one item:

{
  "json": {
    "number1": 5,
    "number2": 3,
    "result": 8
  }
}

If an error occurs during processing of an item (e.g., invalid number or division by zero), the node either throws an error or, if configured to continue on failure, outputs the original item with an error field describing the issue.

This node does not output binary data.

Dependencies

  • No external services or APIs are required.
  • Requires proper configuration of input data fields containing numeric values.
  • No special environment variables or credentials needed.

Troubleshooting

  • Invalid Number Error: If the specified input fields do not contain valid numbers, the node will throw an error indicating which field is invalid. Ensure that the input data fields contain numeric values.
  • Division by Zero: When performing division, if the second number is zero, the node throws an error to prevent division by zero. Check your input data to avoid zero in the divisor field.
  • Unknown Operation: If an unsupported operation is selected, the node will throw an error. Use only the supported operations: add, subtract, multiply, divide, square.
  • Missing Fields: If the specified input fields do not exist in the incoming data, the node will fail. Verify that the field names match exactly.
  • Continue on Fail: If enabled, the node will continue processing other items even if some items cause errors, appending error details to those items.

Links and References

Discussion