Float Nearly Equals
The node that understands binary floats
- nearly_equals
Here's a thing that will eventually bite every ComfyUI user: 0.1 + 0.2 is not 0.3. It's 0.30000000000000004, because that's what binary floating point does. If you've ever written a FLOAT into a widget, compared it against another FLOAT, and watched your graph silently take the wrong branch, you've met this bug. Float Nearly Equals is the fix - it compares two floats using Python's math.isclose with a small relative tolerance (1e-9) and a small absolute tolerance (1e-5), and returns true when they're effectively the same number.
The inputs are a and b, both FLOAT, both defaulting to 0. The single output is a BOOLEAN named nearly_equals. That's the entire surface area.
Mechanically, math.isclose is the standard, boring, correct answer to float comparison: it treats two numbers as equal when their difference is small relative to their size (or small in absolute terms near zero). You could reproduce this with a few nodes, but you'd be rebuilding the standard library in a graph, which is silly. This is the node you drop in when a CFG value, a strength, a denoise, or a sampler output needs to be checked "is it still ~7.0?" without exploding on the 14th decimal place.
It's part of the Gadget/logic family in 2daadv/ComfyUI-GadgetNodes - MIT, one developer, brand-new pack with no community reputation to speak of. Install via ComfyUI Manager (search "GadgetNodes") or git clone https://github.com/2daadv/ComfyUI-GadgetNodes into custom_nodes/ + pip install -r requirements.txt + restart. Pure Python, no JS, works on both the legacy canvas and Nodes 2.0.
Where it earns its keep:
- Comparing a sampler's returned CFG or sigma against a target - the exact case where a strict
==fails randomly. - "Has this strength drifted?" Checks on LoRA strength, denoise, or blend values that round-trip through nodes tend to carry float dust;
iscloseignores dust. - State machines on float inputs. Any logic where a float decides a branch and the value passes through another node in between - tolerance is what makes it stable.
The one thing to keep straight: this is precision tolerance, not policy tolerance. Its absolute tolerance of 1e-5 will not forgive "0.7 vs 0.8" - that's a real difference and should fail. If you want "within one" on whole numbers, the pack's Int Nearly Equals is the one with the human-sized fuzz. Float Nearly Equals is for the arithmetic noise, and it's the right tool for exactly that.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| a | FLOAT | 0.00 | — |
| b | FLOAT | 0.00 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nearly_equals | BOOLEAN | — |