ComfyUI Node

floor

The int conversion that rounds the direction you expect

By StableLlama·Created about a year ago·Updated 4 days ago· 48
floor
  • value
  • INT

floor rounds a number down - toward negative infinity, not toward zero. That distinction is the whole reason this node exists, because ComfyUI's default float-to-int casting truncates toward zero, and the two disagree exactly when it matters: on negatives. floor(-2.7) is -3; a plain cast gives you -2. If you're clamping a value, counting steps, or building an index that needs to never go above a bound, floor is the one that behaves.

The node, from the Basic data handling pack, takes one number and hands back the largest integer less than or equal to it. It's the "round down always" button.

When you'd actually use it

A few concrete spots:

  • Batch and step math. Computing a "safe" integer from a float - how many full tiles fit in a region, how many steps before a threshold - where rounding up would overshoot and rounding toward zero would be inconsistent.
  • Bounds that must never exceed. Floor gives you a ceiling-respecting integer for free. Combine it with a min and you've got a clamp that's readable.
  • Indexing. Data list indices want whole numbers, and floor's "never above" guarantee is friendlier than truncation when your float came from a division.

It also pairs cleanly with ceil (the sibling node, rounds up always). Need to round to the nearest integer? Neither floor nor ceil - use round from the same pack's MathFormula, or the FLOAT rounding node.

How it works

Python's math.floor(): floor(2.9) = 2, floor(2.0) = 2, floor(-2.1) = -3. Note the last one again - down, not toward zero. The output is an INT, not a FLOAT, so it'll happily feed nodes that demand integer inputs like step counts, batch sizes, or get item index sockets.

The input that matters:

  • value - FLOAT or INT, default 0.

Output is INT.

Installing it

Basic data handling is dependency-free and downloads no models - install is the same short story for every node in the pack. Either search "Basic data handling" in ComfyUI Manager and restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling

Restart, and floor lives under Basic/maths.

The gotcha worth remembering

If you're switching from int()-style casting to this node, the negative-number behavior will bite you exactly once. Truncation and floor agree for positive numbers, so your workflow will test clean until a negative float shows up and everything shifts by one. When you see that, you'll know exactly why - and it'll be because you're holding the right node, not a broken one.

CategoryBasic/maths

Inputs (1)

NameTypeDefaultDescription
valueFLOAT,INT0

Outputs (1)

NameTypeDescription
INTINT