Math Negate Integer
The Math Negate Integer node performs a negation operation on an input integer value. It multiplies the input by -1, effectively changing its sign from positive to negative or vice versa.Inputs
a(integer, default: 0): The input integer value to be negated.
Outputs
result(integer): The negated value of the input integer.
Configuration
This node does not have any configuration options.Usage
To use the Math Negate Integer node:- Connect an integer value to the
ainput port. This is the value that will be negated. - The negated value will be available at the
resultoutput port, which can be connected to other nodes in your spell.
Example
Let’s say you have a spell that calculates the difference between two values, but you want to ensure the result is always positive. You can use the Math Negate Integer node to negate the difference if it’s negative. Here’s how the spell might look:- Connect the first value to a Math Subtract node’s
ainput. - Connect the second value to the Math Subtract node’s
binput. - Connect the Math Subtract node’s
resultoutput to a Math Negate Integer node’sainput. - Connect a Math Greater Than node’s
ainput to the Math Subtract node’sresultoutput. - Connect a constant value of 0 to the Math Greater Than node’s
binput. - Connect the Math Greater Than node’s
resultoutput to a Math If node’sconditioninput. - Connect the Math Negate Integer node’s
resultoutput to the Math If node’stheninput. - Connect the Math Subtract node’s
resultoutput to the Math If node’selseinput.
Best Practices
- Be mindful of the input value’s sign. Negating a negative value will make it positive.
- Remember that the Math Negate Integer node only works with integers. For floating-point numbers, use the Math Negate Float node instead.
Common Issues
- Forgetting to handle negative differences: If you subtract a larger number from a smaller one, the result will be negative. Use the Math Negate Integer node in combination with a Math If node to handle this case if needed.
- Incorrect data type: Ensure that the input to the Math Negate Integer node is actually an integer. Connecting a different data type will cause unexpected behavior.
