Nodes/Bjornulf_custom_nodes/๐Ÿงฎ Basic Math
ComfyUI Node

๐Ÿงฎ Basic Math

Add, subtract, multiply across as many inputs as you need

By justUmenยทCreated 2 years agoยทUpdated about a year agoยท 545
๐Ÿงฎ Basic Math
    • FLOAT
    • INT
    • STRING
    โ—„operation+โ–บ
    โ—„num_inputs2โ–บ

    ComfyUI graphs end up needing arithmetic more often than you'd think - comparing a frame count against another frame count, doubling a resolution, working out how many steps are left in a loop. Basic Math is exactly what it sounds like: pick an operator, wire in some numbers, get a result. No frills, which is the point.

    How it works

    Two widgets, both required. operation is a dropdown of the five basics: +, -, *, /, %. num_inputs sets how many number sockets the node shows, from 2 up to 100 - set it to 2 for a simple a - b, or crank it up if you're summing a long chain of values. The operator gets applied across all of them in order, so with - and three inputs you get a - b - c, not three independent subtractions.

    The one real-world example the author gives in the README is using it to spot "missing" frames when comparing two videos - subtract one frame count from another and you know instantly how far off they are. That's the flavor of task this node is built for: quick, disposable arithmetic glue between two other nodes, not a full expression engine.

    The inputs and outputs that matter

    • operation - the operator: add, subtract, multiply, divide, or modulo.
    • num_inputs (2โ€“100) - how many number sockets appear to wire values into.
    • Three outputs come out simultaneously: FLOAT, INT, and STRING versions of the same result. That's a genuinely convenient touch - instead of chasing down a separate "convert to string" or "float to int" node depending on what the next node in your graph expects, you just grab whichever of the three sockets matches.

    How to install it

    Same as the rest of the pack - through ComfyUI Manager, search Bjornulf_custom_nodes and install. Or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/justUmen/Bjornulf_custom_nodes
    

    cd into the folder, pip install -r requirements.txt (a dedicated venv is the safer route), restart ComfyUI. This particular node has no special dependency of its own - it rides on whatever the rest of the pack's requirements.txt needs to import cleanly.

    Common issues

    The one thing worth knowing before you build around this node: with % selected, division-by-zero and integer-vs-float modulo semantics follow normal Python rules, so a zero anywhere downstream in the chain of inputs will error the node rather than silently returning something - if you're feeding it a dynamic value (like a frame-count difference that could legitimately be zero), don't assume it degrades gracefully.

    Because it's part of the shared Bjornulf_custom_nodes package, if the node doesn't show up in your search at all, the more likely culprit isn't this node - it's a missing Python dependency elsewhere in the pack's requirements.txt (the pack also pulls in ollama, opencv-python, civitai-py, and a handful of others for its unrelated video/vision/API nodes) causing the whole custom-nodes folder to fail import. Check the ComfyUI startup console for a traceback before assuming Basic Math itself is broken.

    CategoryUtilities/Math

    Inputs (2)

    NameTypeDefaultDescription
    operationCOMBO+5 options: +, -, *, /, %
    num_inputsINT22โ€“100โ€”

    Outputs (3)

    NameTypeDescription
    FLOATFLOATโ€”
    INTINTโ€”
    STRINGSTRINGโ€”