ComfyUI Node Runs on cloud

Subtract

Subtract one number from another in your graph

By Derfuu·Created 3 years ago·Updated 2 years ago· 455
Subtract
    • FLOAT
    Value_A1.00
    Value_B1.00

    Subtracts one number from another. A − B, output the result. Like the rest of the math nodes in this pack it's about as simple as a node gets, and it earns its place for the same reason: ComfyUI's graph can't do arithmetic on its own, so when you need to compute a difference - an offset, a margin, a padding value - you need an actual node to do it.

    It's a "Math" node from Derfuu_ComfyUI_ModdedNodes, the utility pack for doing calculations on values mid-workflow.

    How it works

    Two float inputs, one float output:

    • Value_A (FLOAT, default 1.0) - the number you subtract from.
    • Value_B (FLOAT, default 1.0) - the amount subtracted.
    • Output FLOAT - A − B. Order matters: Value_A minus Value_B, not the other way around.

    Type the numbers in, or convert the widgets to inputs and wire other nodes in so the subtraction is computed from live values.

    Where you'd use it

    Offsets and margins, mostly. Say you want to crop or paste something 64px in from an edge: read the dimension with Get image size, Subtract 64, and you've got the inset coordinate - and it adapts automatically to any input size. Anywhere you'd think "this value, but a bit less," Subtract is the node.

    It composes with the rest of the pack the obvious way: chain it with Multiply for combined math, feed integers through Int to float to satisfy the type check, and cap the result with Integer when a downstream node wants a whole number.

    Straight talk: for a single subtraction this is clear and fine. For a multi-term formula you'll end up with a spaghetti of these little nodes, and at that point an expression evaluator (like rgthree's Power Puter) that takes width - 64 as text is easier to read. Use the right tool for the size of the math.

    Common issues & troubleshooting

    Got a negative number I didn't expect. You've got Value_A and Value_B swapped. It's A − B; put the larger/base value in A.

    Type mismatch on an input. The ports are floats. Convert an incoming INT with Int to float.

    Result is a decimal, target wants an integer. Add an Integer node to convert float→INT at the end of the chain.

    Node red / missing after an update. Derfuu has a history of deleting old node classes on pack reorganizations instead of deprecating them, so updates can break saved graphs. Update via Manager and re-add.

    Install: ComfyUI Manager → search "Derfuu" → install → restart, or cd ComfyUI/custom_nodes && git clone https://github.com/Derfuu/Derfuu_ComfyUI_ModdedNodes then restart. No models, no heavy dependencies.

    CategoryDerfuu_Nodes/Math

    Inputs (2)

    NameTypeDefaultDescription
    Value_AFLOAT1.00
    Value_BFLOAT1.00

    Outputs (1)

    NameTypeDescription
    FLOATFLOAT