Number Convert
The Adapter Node That Ends Int/Float Type Mismatch Hell
- number_value
- result_int
- result_float
UC_MathNumberConvert takes one number and hands you both an integer version and a float version at once, from two separate outputs. That's it - and it's quietly one of the most useful nodes in the math section, because ComfyUI's type system is picky in a way your arithmetic isn't. Some nodes only accept INT, some only FLOAT, and a value that's mathematically identical is a type error if it's the wrong kind.
Why you'd reach for it
The type mismatch is the whole reason this node exists. Say a math chain produces a float and the downstream widget insists on an integer - instead of rebuilding the chain or hunting for a conversion node, you tap UC_MathNumberConvert and take whichever output matches. It's the adapter in the middle of a graph that doesn't care whether a number "really" is an int or a float, just that the socket says so. Anyone who's fought a "wrong type" error in ComfyUI has wished for exactly this.
How it works
The implementation is two calls in one: int(number_value) for one output and float(number_value) for the other. The details matter:
int()truncates toward zero.2.9becomes2, and-2.9becomes-2. It does not round - if you want nearest, that'sUC_MathRound; if you want up or down, those areUC_MathCeilandUC_MathFloor. Truncation is the naive behavior and it's the one people forget.- The
float()output preserves the value as a float, so a float in gives the same float out and an int in becomes5.0.
The input accepts int or float (the pack's MatchType template), and the two outputs are named result_int and result_float.
The input that matters
number_value - the single number you're adapting. That's the whole interface: one in, two typed outs.
Installing it
It's in ComfyUI-UtilsCollection. ComfyUI Manager → search "ComfyUI-UtilsCollection" → Install → restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/silveroxides/ComfyUI-UtilsCollection
Restart. No models; requirements are just opencv-python and typing-extensions.
What to watch for
Remember the truncation, and you're 90% of the way to not being surprised. The other thing: if you only need one direction (say, float to int), this node still works fine - you just leave one output unwired. And since it's part of the family that replaces ComfyUI-LogicMath, accept the swap prompt if you're migrating and uninstall the old pack to avoid duplicate nodes. Small, boring, and it saves you the exact kind of error that eats an hour.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| number_value | COMFY_MATCHTYPE_V3 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| result_int | INT | — |
| result_float | FLOAT | — |