Nodes/ComfyUI GOAT Nodes/🐐 Capped Int (Positive)
ComfyUI Node

🐐 Capped Int (Positive)

A hard ceiling for an integer, without a math node

By AconexOfficialΒ·Created 2 years agoΒ·Updated 12 months agoΒ· 11
🐐 Capped Int (Positive)
    • INT
    β—„int0β–Ί
    β—„cap10β–Ί

    This is about as small as a ComfyUI node gets, and that's the point. Capped Int (Positive) takes an integer and clamps it to a maximum - that's the entire job. It exists so you don't have to reach for a full math-expression node or chain a min() operation together every time you need a value that's, say, "whatever this upstream node produces, but never more than 8" - a batch size that shouldn't blow your VRAM, a step count you don't want a user-facing workflow to push past, that kind of thing.

    How it works

    Two inputs, int and cap, one output: whichever is smaller. There's one behavior worth knowing before you wire this in: a cap of 0 means uncapped, not "clamp everything to zero." That's a deliberate design choice - 0 is being used as a sentinel for "no limit" rather than a literal ceiling - but it's exactly the kind of thing that bites you if you assume cap behaves like a normal minimum function. If you actually want to force a value down to zero, this isn't the node for it; set cap to any positive number for a real ceiling.

    Inputs and outputs that matter

    • int (0 to 2,147,483,647 - the standard 32-bit signed integer range) - the value you're clamping. Note the node's own range floor is 0, so this is built for non-negative values by design, matching the "Positive" in its name.
    • cap (same range, default 10) - the ceiling. Remember: 0 = uncapped, not zero.

    One output: INT - int, or cap, whichever is lower (unless cap is 0, in which case it's just int unchanged).

    How to install it

    ComfyUI Manager: search "GOAT Nodes", install, restart. Or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/AconexOfficial/ComfyUI_GOAT_Nodes.git
    

    then restart ComfyUI. There's genuinely nothing to it beyond that - no dependencies, no models, it's a two-input math primitive.

    Common issues & troubleshooting

    "I set cap to 0 and my value didn't get zeroed." That's not a bug - it's the documented behavior. A cap of 0 is the pack's way of expressing "no cap," which is a reasonable design when you want a single widget to toggle between "limited" and "unlimited" without a separate boolean switch, but it's the one thing about this node you need to remember before you rely on it. If you genuinely need to force something to zero conditionally, use a comparison or switch node instead.

    Wondering why this exists instead of a generic math node. Fair question - a min(a, b) node from any math-utility pack does the same thing. The value here is purely ergonomic: one purpose-built node with clearly named inputs (int, cap) reads faster in a crowded graph than a generic two-input math node set to "minimum" mode, especially months later when you're trying to remember what your own workflow does. If you're not bothered by that, any math node with a min operation is a fine substitute - this one just saves you the extra click of picking an operation from a dropdown.

    Category🐐 GOAT Nodes/Math

    Inputs (2)

    NameTypeDefaultDescription
    intINT00–2147483647β€”
    capINT100–2147483647β€”

    Outputs (1)

    NameTypeDescription
    INTINTβ€”