Nodes/JNComfy/TO FLOAT
ComfyUI Node

TO FLOAT

Cast anything to a float, with real rounding control

By jn-jairo·Created 2 years ago·Updated 2 years ago· 5
TO FLOAT
  • value
  • FLOAT
decimal_places0
round_method

A type cast to FLOAT, plus actual control over how the result gets rounded - which is the part that separates this from a bare float() call and is worth understanding before you rely on it.

It's part of JNComfy (jn-jairo/jn_comfyui), a one-person pack spanning audio, face restoration, and a family of small conversion primitives like this one. There's essentially no community discussion of the pack anywhere, so the README and the node's own schema are the whole picture - there isn't a bigger thread to fall back on if something doesn't behave the way you expect.

How it works

value accepts anything, thanks to the generic typing this pack leans on throughout its Primitive family. round_method picks how (or whether) the result gets rounded: disabled does a raw cast with no rounding applied at all; truncate chops toward zero; round applies standard rounding to the nearest value; floor always rounds down; ceil always rounds up. decimal_places (minimum 0) sets how many digits survive - but only when a real rounding mode is active.

That last point is the trap: decimal_places has no effect on its own. Set it to 2 but leave round_method on disabled, and you'll get the full, unrounded float back - the two settings only work together, not independently.

The practical use case is cleaning up a number before it hits something that displays it or compares it exactly - an upstream calculation that leaves you with 0.30000000000000004-style floating-point noise is exactly what round_method: round with decimal_places: 2 is for, turning that into a clean 0.3 rather than carrying the noise forward.

The inputs and outputs that matter

  • value (required, any type) - what you're casting.
  • decimal_places (required, INT, default 0, minimum 0) - digits kept, when rounding is active.
  • round_method (required, one of disabled / truncate / round / floor / ceil) - how rounding is applied.
  • Output: FLOAT.

Installing it

ComfyUI Manager: search "JNComfy". Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/jn-jairo/jn_comfyui

Restart ComfyUI. No models, no dependencies.

Common issues & troubleshooting

decimal_places looks like it's being ignored. Check round_method first - it almost certainly is on disabled. That setting has to be something other than disabled for decimal_places to matter at all.

Casting a non-numeric string errors out. This is a cast, not a parser - feed it something like "banana" and expect an error, not a silent 0. If the value might genuinely not be numeric, validate it upstream before it reaches this node.

floor and truncate disagree on a negative number. They're not the same thing once numbers go negative: truncate chops toward zero (-1.7-1), while floor always rounds down toward negative infinity (-1.7-2). If you're seeing an "off by one" on negative values specifically, that distinction is almost certainly why.

CategoryJN/Primitive/Conversion

Inputs (3)

NameTypeDefaultDescription
value*
decimal_placesINT00–18446744073709550000
round_methodCOMBO5 options: disabled, truncate, round, floor, ceil

Outputs (1)

NameTypeDescription
FLOATFLOAT