IsNaN
Float
isNaN (float)
The isNaN
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):true
if the input is NaN,false
otherwise.
Configuration
This node has no configuration options.
Usage
The isNaN
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
a
input port. - The
result
output port will emittrue
if the input is NaN, andfalse
otherwise. - Use the
result
output 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 the isNaN
node in a spell:
In this example:
- The
input/number
node allows the user to enter a number. - The
isNaN
node checks if the input number is NaN. - The
logic/branch
node uses theresult
fromisNaN
to 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
isNaN
node when you need to explicitly check for NaN values, such as in data validation or error handling scenarios. - Remember that
isNaN
only checks for NaN values, not other types of invalid numbers like infinity or undefined.
Common Issues
- Ensure that the input to the
isNaN
node is of typefloat
. Connecting a non-float value may lead to unexpected behavior. - Keep in mind that
isNaN
will returnfalse
for non-numeric values like strings or booleans. If you need to check for these cases, consider using additional type-checking nodes.