isNaN (float)
TheisNaN node checks if the input value is not a number (NaN). It returns true if the input is NaN, and false otherwise.
Inputs
a(float, default: 0): The value to check for NaN.
Outputs
result(boolean):trueif the input is NaN,falseotherwise.
Configuration
This node has no configuration options.Usage
TheisNaN node is useful when you need to determine if a value is not a valid number. This can be helpful in data validation, error handling, or conditional logic based on the presence of NaN values.
To use the isNaN node:
- Connect the value you want to check for NaN to the
ainput port. - The
resultoutput port will emittrueif the input is NaN, andfalseotherwise. - Use the
resultoutput in your spell logic as needed, such as in a branch node or as a condition for further processing.
Example
Here’s an example of how to use theisNaN node in a spell:
- The
input/numbernode allows the user to enter a number. - The
isNaNnode checks if the input number is NaN. - The
logic/branchnode uses theresultfromisNaNto conditionally route the flow. - If the input is NaN, the “The input is NaN” message is displayed.
- If the input is a valid number, the “The input is a valid number” message is displayed.
Best Practices
- Use the
isNaNnode when you need to explicitly check for NaN values, such as in data validation or error handling scenarios. - Remember that
isNaNonly checks for NaN values, not other types of invalid numbers like infinity or undefined.
Common Issues
- Ensure that the input to the
isNaNnode is of typefloat. Connecting a non-float value may lead to unexpected behavior. - Keep in mind that
isNaNwill returnfalsefor non-numeric values like strings or booleans. If you need to check for these cases, consider using additional type-checking nodes.
