Nodes/WtlNodes/Int ↔ Float
ComfyUI Node

Int ↔ Float

The type converter that rounds instead of truncates

By Scorpiosis0·Created 10 months ago·Updated 2 months ago· 3
Int ↔ Float
  • value
  • result
cast_to_intfalse

ComfyUI is picky about number types, and that pickiness is a real problem when one node hands you a float and the next node's socket only accepts ints. WtlCast is the fix: take any INT or FLOAT in through value, flip the cast_to_int toggle, and get the converted number back out as result.

The one decision this node makes for you is worth calling out: when converting a float to an int, it rounds - int(round(value)) - rather than truncating. So 3.6 becomes 4, not 3. That's friendlier than Python's bare int() behavior and usually what you actually want when you're snapping a computed value to a steps count or a seed. If you were relying on truncation you'd need to subtract 0.5 first, but for the common cases - round a denoise-derived number to the nearest step - this is the right default.

The cast_to_int toggle defaults to off, which sends the value the other way, to float. That direction is mostly a formality since ints flow into float sockets without complaint; the interesting half of this node is the int direction. You'll reach for it when a scheduler, a math chain, or a text-parsed number delivers a float and the downstream node - batch count, seed, steps, aspect-ratio ints - refuses to accept it.

It's part of the WtlNodes logic family, so install the pack once. ComfyUI Manager (search "WtlNodes") or:

cd ComfyUI/custom_nodes
git clone https://github.com/Scorpiosis0/ComfyUI-WtlNodes.git

then restart ComfyUI. Only numpy, scipy, and pillow as dependencies; no models or keys to fetch.

One thing to remember: WtlCast is a plain type converter, not a "format this nicely" node. If your float is 3.0000001 you'll get 3 after rounding to int, which is fine - but don't expect it to clean up a string or handle anything that isn't already a number. It's a tiny, sharp tool, and the rounding behavior is the detail that makes it worth having over a DIY conversion.

CategoryWtlNodes/logic

Inputs (2)

NameTypeDefaultDescription
valueINT,FLOAT
cast_to_intBOOLEANfalse

Outputs (1)

NameTypeDescription
resultINT,FLOAT