4 min read

Multiplytwonumbers

Overview

The node is designed to perform multiplication on two numerical inputs. It takes either direct inputs or configuration settings, processes these inputs, and returns their product. This functionality is essential for applications requiring mathematical operations, such as financial calculations, statistical analyses, and problem-solving scenarios involving quantitative data.

Settings

The node includes various settings that can be configured to influence its operation. Below is a detailed breakdown of each setting:

1. inputs

2. input1

3. input2

Error Handling

How It Works

  1. Input Gathering: The function retrieves values for input1 and input2 either from the inputs object or from the config object.
  2. Parsing to Numbers: Both values are converted to numbers using Number() to ensure they are in a suitable format for multiplication.
  3. Validation: It checks if either of the converted values is not a number using isNaN(). If either value fails this check, it throws an error.
  4. Multiplication: If both inputs are valid numbers, it computes the product of input1 and input2.
  5. Return Value: Finally, the function returns an object containing the result of the multiplication in the output1 key.

Data Expectations

The node expects two numerical inputs, which can either be provided directly through an object when invoking the function or via configuration parameters. Inputs must be of numeric type or convertible to numbers. If the inputs are invalid, an error is thrown, making proper validation essential for the function's successful execution.

Example of Valid Data:

json
{
    "inputs": {
        "input1": 5,
        "input2": 10
    },
    "config": {}
}

Use Cases & Examples

Use Cases

  1. Financial Applications: Utilize this node to calculate total costs by multiplying unit prices with quantities sold.
  2. Statistical Data Validations: Validate numerical data inputs by ensuring they can be multiplied to derive products in analytical applications.
  3. Mathematical Simulations: Implement this logic in mathematical software that requires various calculations, such as educational platforms for teaching multiplication concepts.

Detailed Example

Use Case: Calculating Total Sales from Unit Price and Quantity Sold.

Configuration Data: Suppose a business needs to determine the total income from selling 40 units of a product priced at $25 each.

Example Configuration:

json
{
    "inputs": {
        "input1": 25,
        "input2": 40
    },
    "config": {}
}

Expected Output: When the node is executed with the above configuration, the output will be:

json
{
    "output1": 1000
}

This indicates that the total sales amount is $1000 (25 multiplied by 40).