Nodes/MD Nodes/MD: Math Subtract (Int/Float)
ComfyUI Node

MD: Math Subtract (Int/Float)

A − B with both output types, for the times you just need a difference

By MDMAchine·Created about a year ago·Updated 3 months ago· 15
MD: Math Subtract (Int/Float)
    • int_result
    • float_result
    a0.00
    b0.00

    MD_Math_Subtract is the subtraction half of MD Nodes' basic math set: feed it two numbers, get a - b back as both an integer and a float. That's the entire node, and it's the right scope. In a workflow you spend most of your time adding and scaling; subtraction is for the smaller moments - computing how many steps remain, the difference between a target size and what you have, or offsetting a value back to zero.

    What justifies reaching for it over ComfyUI's built-in math is the same dual-output trick as the pack's other math nodes: int_result and float_result come out of one node, so you wire whichever type the next node accepts and never think about it again.

    How it works

    Two FLOAT inputs, a and b. The math is a - b, no surprises - the tooltip even spells out the logic as "Result = A - B". Both results are produced from the same inputs; the int version is the truncated result. Inputs are full-range floats, so negative differences and fractional results are fine.

    The inputs that matter

    • a - the starting number, the thing being subtracted from.
    • b - the amount removed.

    Outputs: int_result and float_result. Plug whichever one your target node's input type asks for.

    Installing

    Part of the MD Nodes pack:

    cd path/to/ComfyUI/custom_nodes
    git clone https://github.com/MDMAchine/ComfyUI_MD_Nodes.git
    cd ComfyUI_MD_Nodes
    pip install -r requirements.txt
    

    Or via ComfyUI Manager, search MD Nodes, install, restart. No dependencies beyond Python itself - it works even if you skip the pack's heavy requirements (those exist for the audio nodes).

    Common issues

    Only one real gotcha, and it's a habit thing: remember which argument is which. Swap them and you get a negated result that can silently break a downstream calc - there's no visual "order" cue beyond the input names. If you're subtracting a step count or a dimension, wire a from the source and b from the thing you're removing, and sanity-check the sign when you first build the graph. Otherwise it's a zero-surprise utility: if all you need is a difference with both output types, this is a one-node answer.

    CategoryMD_Nodes/Math

    Inputs (2)

    NameTypeDefaultDescription
    aFLOAT0.00-1.797e+308–1.797e+308VALUE A (PRIMARY) • Purpose: The starting number. • Range: Full float range. ⭐ The number being subtracted FROM.
    bFLOAT0.00-1.797e+308–1.797e+308VALUE B (SUBTRAHEND) • Purpose: The amount to remove from A. • Range: Full float range. ⭐ Logic: Result = A - B

    Outputs (2)

    NameTypeDescription
    int_resultINT
    float_resultFLOAT