Let’s say you have a spell that calculates the average of a list of numbers, but you want to display the result as an integer. You can use the TRUNC node to remove the fractional part of the average.Here’s how the spell might look:
Use a LIST node to define the list of numbers.
Connect the LIST node to an AVERAGE node to calculate the mean value.
Connect the AVERAGE node’s output to the TRUNC node’s a input.
The truncated integer result will be available at the TRUNC node’s result output.
Use TRUNC when you need to convert a floating-point number to an integer without rounding. If you want to round to the nearest integer, consider using the ROUND node instead.
Keep in mind that TRUNC always rounds towards zero. For negative numbers, this means rounding up towards zero.
If the input is already an integer, TRUNC will have no effect and will return the same value.
TRUNC does not change the data type of the input. The result will still be a floating-point number, even though it has no fractional part. If you need the result as an actual integer data type, consider using a type conversion node after TRUNC.