Nodes/JNComfy/TO INT
ComfyUI Node

TO INT

Cast anything to an integer, your choice of rounding

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

A type cast to INT, with a choice of rounding rule rather than a fixed, silent one - the sibling to JN_PrimitiveToFloat, minus the decimal-places control, since an integer output doesn't have decimals to keep.

It's part of JNComfy (jn-jairo/jn_comfyui), a one-person pack covering audio, face restoration, sampling patches, and this family of small conversion nodes. There's no meaningful community discussion of the pack anywhere, so what's in the README and the node's own schema is genuinely the full picture rather than a starting point for further searching.

How it works

value is typed generically, so it'll accept whatever you hand it - most commonly a FLOAT coming from some upstream math. round_method decides how a fractional value gets resolved into a whole number: truncate chops toward zero, round applies standard nearest-value rounding, floor always rounds down, ceil always rounds up. Unlike the float version of this node, there's no disabled option here - an INT output has to land on some whole number, so a rounding decision is unavoidable rather than optional.

The one distinction actually worth internalizing: truncate and floor agree for positive numbers and disagree for negative ones. truncate(-1.7) gives -1 (toward zero); floor(-1.7) gives -2 (toward negative infinity). If your graph only ever deals in positive values this never bites you - the moment a negative number shows up, it can.

round is the one to reach for by default when you just want the nearest whole number and don't have a specific reason for one of the directional modes; ceil/floor earn their place when you need a guaranteed upper or lower bound instead of the closest value - sizing a grid so it never comes up short, for instance.

The inputs and outputs that matter

  • value (required, any type) - what you're casting.
  • round_method (required, one of truncate / round / floor / ceil) - how the fractional part is resolved.
  • Output: INT.

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

Off-by-one on a negative value. This is almost always truncate vs. floor disagreeing, as above. If the result is one lower or higher than you expected, check which rounding mode is set before assuming something else is broken.

Casting text fails outright. Non-numeric input isn't silently coerced to 0 - expect a real error. Validate the value upstream if there's any chance it isn't actually numeric.

Result seems to round the "wrong" way on a .5 value. round follows the underlying language's standard rounding behavior, which for exact halfway values doesn't always round up the way grade-school rounding does. If a .5 case matters to your workflow, test it directly with a JN_Dump on the output rather than assuming.

CategoryJN/Primitive/Conversion

Inputs (2)

NameTypeDefaultDescription
value*
round_methodCOMBO4 options: truncate, round, floor, ceil

Outputs (1)

NameTypeDescription
INTINT