Nodes/ComfyUI_Mira/Integer Subtraction
ComfyUI Node

Integer Subtraction

Subtract, and pass the amount through

By mirabarukaso·Created 2 years ago·Updated 5 days ago· 206
Integer Subtraction
    • Result (INT)
    • Result (STRING)
    • subtracted_value
    int_value0
    subtracted_value0

    Subtract one integer from another. Like its multiply and add siblings, it's a small arithmetic helper for when a workflow needs a computed number rather than a typed constant. What makes this one slightly more than a calculator is a third output: it also passes the subtracted amount straight through, which turns out to be exactly what you need for one specific, fiddly job in the pack.

    That job is positioning masks. The author calls it out directly: this node's main use is with Create Mask With Canvas. When you're placing a mask by coordinates and you want it anchored to the bottom of a canvas rather than the top, you compute Y = canvas_height − mask_height, then you need that same mask height fed to the mask's Height input. Subtraction gives you both from one node - the computed Y on one output, the height it subtracted on another - so the two stay linked when you change either.

    How it works

    It takes int_value and subtracted_value, computes int_value − subtracted_value, and gives you three outputs: the result as an INT, the result as a STRING (for display), and the subtracted_value passed through unchanged. That pass-through is the design flourish - it lets one node both do the math and forward the operand that a downstream node also needs.

    The inputs that matter

    • int_value - the number you're subtracting from.
    • subtracted_value - the amount to subtract, which is also echoed on an output.

    Outputs: Result (INT), Result (STRING), and subtracted_value (the amount, passed through).

    Where it fits

    The canonical wiring, straight from the readme: feed a canvas height into int_value and your mask height into subtracted_value; wire Result (INT) into the mask's Y position and subtracted_value into the mask's Height. Now your mask sits flush against the bottom edge and follows automatically when you resize it. More generally, use it any time one value is derived from another by subtraction and both need to travel downstream.

    Install

    ComfyUI Manager → Custom Nodes Manager → search ComfyUI_Mira → Install → restart. Or by hand: cd ComfyUI/custom_nodes && git clone https://github.com/mirabarukaso/ComfyUI_Mira.git, then restart. If the pack errors on load, run pip install -r requirements.txt in its folder. No downloads.

    Common issues

    Both inputs default to 0, so an untouched, unconnected node just outputs 0 - wire the values. Watch for negative results: this is integer subtraction, and if subtracted_value exceeds int_value you'll get a negative number, which a mask position or dimension input won't accept. Make sure the value you're subtracting from is the larger one for coordinate math. And if you need decimals, this is the integer node - there's a float multiplier for fractional work, though for subtraction specifically you're in whole numbers here.

    CategoryMira/Arithmetic

    Inputs (2)

    NameTypeDefaultDescription
    int_valueINT0
    subtracted_valueINT0

    Outputs (3)

    NameTypeDescription
    Result (INT)INT
    Result (STRING)STRING
    subtracted_valueINT