Round
This node rounds a number to the nearest integer.
The Round node performs standard mathematical rounding.
The Round node takes a numeric input and rounds it to the nearest integer. Values with a fractional part of .5 or greater round up, while less than .5 round down. For example, 4.5 becomes 5, 4.4 becomes 4.
Inputs
Input
| Data | Description |
|---|---|
| Value | The number to round. Default: 0. |
Actions
| Signal | Description |
|---|---|
| Do | Triggers the calculation. The result is updated only when this signal is received. |
Outputs
Data
| Data | Description |
|---|---|
| Rounded Value | The rounded integer result. |
Signals
| Signal | Description |
|---|---|
| Done | Triggered when the calculation is successfully completed. |
Usage
Use this node for general-purpose rounding where you want the closest whole number.
Example Use Cases
- UI Display: Showing a clean integer score instead of a float.
- Snapping: Snapping an object position to the nearest grid line.
- Statistics: Rounding averages to whole numbers.
Detailed Behavior
- Validation:
- Input must be a valid number.
- Input and Result must be within ±1,000,000,000,000.
- Calculation:
- Uses
Math.round(). - Triggered only by the
Dosignal.
- Uses
- Error Handling:
- If the result exceeds the allowed range, an error is logged and
Doneis not signaled.
- If the result exceeds the allowed range, an error is logged and
Troubleshooting
- Midpoint Rounding:
Math.round()rounds.5up towards positive infinity.-4.5becomes-4, and4.5becomes5.