ComfyUI Node

Integer Maximum

Take the larger of two integers in your graph

By jamesWalker55·Created 3 years ago·Updated about a year ago· 215
Integer Maximum
    • INT
    a0
    b0

    JWIntegerMax does one thing, and it does it without drama: it takes two integers, a and b, and outputs whichever is larger. That's max(a, b). If a is 512 and b is 768, you get 768. If they're equal, you get that value. There is nothing else to it, and that's the appeal.

    It's part of jamesWalker55's "Various ComfyUI Nodes by Type" pack, specifically the primitive-ops file, which is a whole family of tiny math and logic nodes: integer add, subtract, multiply, min, max, plus float and string equivalents. These exist because for a long time ComfyUI's core had thin support for doing arithmetic inside a graph, and if you wanted to compute a dimension or clamp a value on the fly, you were stuck. Single-purpose nodes like this filled the gap.

    Why you'd reach for it

    The honest use case is guarding a number so it never dips below a floor. Say you're deriving an image dimension from some upstream calculation and you never want it smaller than 512. Wire your computed value into a, put 512 in b, and the output is your value or 512, whichever is bigger. Same trick for a minimum step count, a minimum batch size, or making sure a shorter-side resize never goes below a model's comfort zone. Pair it with JWIntegerMin from the same pack and you've got a poor man's clamp: max to enforce a floor, min to enforce a ceiling.

    Is this the only way to do it? No. rgthree's Power Puter evaluates python-like expressions mid-graph, and there are math nodes in other packs and in newer ComfyUI itself. But there's a real argument for the dumb single-purpose node: a graph that says "Integer Maximum" in plain text is readable at a glance six months later, whereas an expression buried in a general-purpose node isn't. When the value of a node is that the next person (probably you) can see what it does without opening it, these little primitives earn their place.

    The inputs and output

    • a (default 0): the first integer.
    • b (default 0): the second integer.

    Both accept an enormous range (roughly plus or minus 1.8e19), so you will never hit the limit in any realistic workflow. The output is a single INT carrying the larger of the two, ready to feed a resolution field, a step count, a loop bound, or another math node.

    Installing it

    Through ComfyUI Manager: search "Various ComfyUI Nodes by Type" or the author jamesWalker55, install, restart. Or clone it yourself:

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

    then restart ComfyUI. No models, no dependencies, nothing to download. It's arithmetic.

    Anything to watch out for?

    Almost nothing, which is the nicest thing about it. The one conceptual snag is that this is integer max, so both inputs get treated as whole numbers. If you're working with fractional values, you want the float version (JWFloatMax) instead, or you'll be comparing rounded numbers and wondering why the answer is off by a bit. And remember it takes exactly two inputs, so if you need the max of three or four values, chain a couple of these together (feed the output of one into the a of the next). That's the intended way to do it, not a hack.

    CategoryjamesWalker55

    Inputs (2)

    NameTypeDefaultDescription
    aINT0-18446744073709550000–18446744073709550000
    bINT0-18446744073709550000–18446744073709550000

    Outputs (1)

    NameTypeDescription
    INTINT