MD: Math Subtract (Int/Float)
A − B with both output types, for the times you just need a difference
- int_result
- float_result
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.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| a | FLOAT | 0.00-1.797e+308–1.797e+308 | VALUE A (PRIMARY) • Purpose: The starting number. • Range: Full float range. ⭐ The number being subtracted FROM. |
| b | FLOAT | 0.00-1.797e+308–1.797e+308 | VALUE B (SUBTRAHEND) • Purpose: The amount to remove from A. • Range: Full float range. ⭐ Logic: Result = A - B |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| int_result | INT | — |
| float_result | FLOAT | — |