Nodes/antrobots ComfyUI Nodepack/Percentage of Total
ComfyUI Node

Percentage of Total

Percentage of Total

By antrobot1234·Created 3 years ago·Updated about a year ago· 28
Percentage of Total
    • INT
    total20
    percentage0.50

    calc takes a total and a percentage and gives you back the integer that percentage represents. Feed it 20 and 0.5, get 10. That's it. It's a tiny math node, and it exists to solve one specific annoyance: expressing a step count as a fraction instead of a hardcoded number.

    Why you'd reach for it

    Here's the scenario it's built for. You're running a base+refiner or a two-stage sampler and you want the switchover to happen "halfway through," or "at 70%." If your total steps is 20, halfway is step 10 - fine. But then you bump total steps to 30 and now your hardcoded "10" is a third of the way in, not half. The relationship you actually meant - half of the total - got baked into a constant and quietly broke.

    calc keeps the relationship live. Wire your total steps into total, set percentage to 0.5, and its output tracks the total automatically. Change the step count anywhere and the switch step follows. This is exactly the kind of thing you want feeding the refine_step input on this pack's KSampler with Refiner or KSampler with Pipes - set the split as a percentage once and stop re-deriving it every time you tune step counts.

    How it works

    It multiplies total by percentage and returns the result as an integer. percentage is a 0–1 float (so 0.5 is 50%, not 50), and the output is rounded to a whole number because the things you feed it into - step indices, pixel counts - need to be integers.

    The inputs and outputs

    • total - the whole amount, as an integer (default 20). Usually your total step count, but it works for any total: a dimension, a frame count, whatever.
    • percentage - the fraction, 0 to 1 (default 0.5). 0.25 = a quarter, 0.75 = three quarters.

    The output is a single INT - total x percentage, rounded.

    Installing it

    ComfyUI Manager → search antrobots ComfyUI Nodepack, install, restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/antrobot1234/antrobots-comfyUI-nodepack
    

    No models, no dependencies.

    Common issues

    The one thing that catches people is the scale of percentage: it's 0–1, not 0–100. If you type 50 expecting fifty percent, the node clamps to its max of 1 and you'll get back your full total every time. Use 0.5.

    Otherwise it's about as foolproof as a node gets. Just remember the output is rounded to an integer, so at small totals the rounding is chunky - 33% of 10 steps is 3, not 3.3 - which is fine for step counts but worth knowing if you were expecting exactness.

    Categoryantrobots-ComfyUI-nodepack/math

    Inputs (2)

    NameTypeDefaultDescription
    totalINT201–10000
    percentageFLOAT0.500–1

    Outputs (1)

    NameTypeDescription
    INTINT