Math node
Compare
Compares two numeric values using a relational operator and outputs a boolean result. An adjustable tolerance creates a deadband around the comparison threshold, preventing rapid toggling when real-time data hovers near a boundary.
Inputs
| Port | Type | Default |
|---|---|---|
| AThe left-hand value of the comparison. Any number works; whole numbers are read as decimals. Also accepts an ARRAY — compares element-wise, Result becomes a bool array. | float | 0 |
| ==Which comparison to run — equal, not equal, less, greater, or the or-equal variants. The port label follows your choice; values outside the list fall back to equal. | int | 0 |
| BThe right-hand value of the comparison, the one A is measured against. Arrays compare element-wise (a number broadcasts). | float | 0 |
| ToleranceA deadband around B that stops jittery realtime data from flickering the result. The sign is ignored and the true zone always widens; 0 compares exactly. | float | 0 |
Outputs
| Port | Type |
|---|---|
| Result | bool |
How It Works
The Compare node evaluates a relational expression between inputs A and B using the selected operator:
| Operator | Symbol | Description |
|---|---|---|
| Equal | == | True when A equals B (within tolerance) |
| Not Equal | != | True when A does not equal B (outside tolerance) |
| Less Than | < | True when A is less than B |
| Greater Than | > | True when A is greater than B |
| Less or Equal | <= | True when A is less than or equal to B |
| Greater or Equal | >= | True when A is greater than or equal to B |
The Tolerance input adds a deadband to the comparison. For equality checks, A is considered equal to B when the absolute difference between them is less than or equal to the tolerance value. This is critical when working with real-time sensor data, physics simulations, or any floating-point values that fluctuate near a threshold — without tolerance, the output can rapidly toggle between true and false, causing unstable downstream behavior.
For inequality operators (<, >, <=, >=), tolerance shifts the effective threshold, providing hysteresis-like behavior that stabilizes the output.
Use Cases
- Triggering events when a value crosses a threshold (e.g., volume exceeds 0.8)
- Checking equality between floating-point values with a safe tolerance margin
- Building conditional branches in the graph based on numeric comparisons
- Creating deadbands for real-time sensor data to prevent jittery outputs
- Gating animations or effects based on whether a parameter is within a range
Tips
- Always use a small tolerance (e.g., 0.001) when comparing floating-point values for equality; exact equality with floats is unreliable
- Tolerance is especially important for real-time data sources like Mouse, EEG, or audio levels that fluctuate rapidly
- Chain two Compare nodes to test whether a value falls within a range (A > low AND A < high)
- The operator picker can be connected to a dynamic source to change the comparison at runtime
- Combine with Logic nodes to build compound conditions from multiple comparisons
Open Compare in the interactive catalog →
Compare is one of 381 nodes in Grafit Pro.
Free download. Every feature for 7 days, no card. Then €99.99 once — or keep playing your projects as a Player.