ComfyUI Node

Float Subtract

Subtract one float from another in ComfyUI

By jamesWalker55·Created 3 years ago·Updated about a year ago· 215
Float Subtract
    • FLOAT
    a0.00
    b0.00

    Need the difference between two numbers without leaving the graph? JWFloatSub does a - b and hands you the result as a float. It's one of the small primitive math nodes in James Walker's grab-bag pack, and it earns its place any time you're computing an offset, a remainder, or a gap.

    Subtraction shows up more than you'd think once you start driving values with wires. How many steps are left after a first pass? Total minus done. How far is this value from a target? Value minus target, maybe wrapped in an absolute-value node afterward. What's the margin between two dimensions? One minus the other. Doing it as a live node means the answer updates itself when either input moves - you're not re-deriving it by hand every time you tweak a slider upstream.

    What it actually does

    a minus b, both FLOAT, one FLOAT out. Defaults are 0 for each, and the min/max are set so wide (±1e17) you can forget they exist. Straightforward as it gets: no rounding, no clamping, just the difference.

    The natural partner is JWFloatAbsolute from the same pack - subtract to get a difference, then take the absolute value when you only care about magnitude and not which way it went. And if you want to guarantee the result never dips below some floor, chain a JWFloatMax after it.

    The inputs and outputs that matter

    Two required inputs, one output:

    • a - the value you're subtracting from (FLOAT).
    • b - the value you're subtracting (FLOAT).

    Output is a single FLOAT equal to a - b. Feed it wherever a float belongs - a step count, an offset, the next math node in line.

    How to install it

    The pack is jamesWalker55/comfyui-various. In ComfyUI Manager, search Various ComfyUI Nodes by Type, install, restart. Or from the command line:

    cd ComfyUI/custom_nodes
    git clone https://github.com/jamesWalker55/comfyui-various
    

    then restart. Zero dependencies for the math nodes. If you'd rather not clone the whole repo, the author's own advice is to grab a single file - every Float and Integer node sits in comfyui_primitive_ops.py, so that one file is all you need for arithmetic. Keeping your node list lean is a real quality-of-life win in a busy ComfyUI install.

    Common issues & troubleshooting

    Sign confusion. a - b, not b - a. If your result is negative when you expected positive, you've got the inputs swapped. The node won't warn you - it'll happily hand a negative number downstream, where it might silently break a node that expects a positive value.

    One multiply-add-subtract chain vs. an expression node. Same caveat as the rest of this family: if you're wiring three or four of these together, a single math-expression node from a newer pack will read cleaner. JWFloatSub's whole appeal is that it's boring, dependency-free, and impossible to misconfigure beyond swapping two inputs.

    CategoryjamesWalker55

    Inputs (2)

    NameTypeDefaultDescription
    aFLOAT0.00-100000000000000000–100000000000000000
    bFLOAT0.00-100000000000000000–100000000000000000

    Outputs (1)

    NameTypeDescription
    FLOATFLOAT