ComfyUI Node

Largest Int (JPS)

Compare two integers and get the bigger one, the smaller one, and which was which

By JPS-GER·Created 3 years ago·Updated 2 years ago· 100
Largest Int (JPS)
    • larger_int
    • smaller_int
    • is_a_larger
    int_a1
    int_b1

    ComfyUI doesn't ship a built-in "which of these two numbers is bigger" node, which sounds trivial until you actually need one mid-graph - say, comparing an image's width against its height to decide crop orientation, or figuring out which of two computed resolutions should drive a downstream Empty Latent Image. This node is that missing comparator, done once so you don't have to fake it with a chain of subtract-and-check nodes.

    You give it two integers, int_a and int_b (both default to 1), and it hands back three things: larger_int (whichever value was bigger), smaller_int (whichever was smaller), and is_a_larger - a flag telling you which input actually won the comparison, so downstream logic can branch on which of the two inputs was larger, not just what the larger value happened to be. That last output is the part that turns this from "a max() function" into something you can actually build conditional logic around in a node graph, where there's no if-statement to reach for otherwise.

    Where you'd actually use this. The most natural fit is resolution math: you've got a width and a height for an image (from Get Image Size (JPS), say) and you need to know which dimension is dominant before deciding how to crop, pad, or which axis to base an aspect-ratio calculation on. It's also handy any time you're comparing two independently-computed values - two candidate upscale targets, two strength values from different sources - and want to route the winner into a single downstream input without manually picking one every time you change a setting upstream.

    Installing it. Via ComfyUI Manager (search "JPS Custom Nodes for ComfyUI"), or by hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/JPS-GER/ComfyUI_JPS-Nodes.git
    

    Restart ComfyUI, and it's under JPS Nodes/Math. If upgrading from an older copy of the pack, delete the previous version first - the author is explicit about this to avoid class-name collisions between two installs of the same node set. No models, no extra dependencies; it's a plain comparison.

    Troubleshooting. This node is small enough that there's not much to debug independently of the rest of your graph. The one thing to actually check if a downstream decision seems inverted: confirm which output you wired where. It's an easy mistake to plug smaller_int into a slot where you meant larger_int, especially once a graph has a few of these compare nodes stacked and the wires start crossing. If in doubt, temporarily route each output to a Preview/Text node and confirm the values match what you expect before trusting the logic further downstream.

    CategoryJPS Nodes/Math

    Inputs (2)

    NameTypeDefaultDescription
    int_aINT1
    int_bINT1

    Outputs (3)

    NameTypeDescription
    larger_intINT
    smaller_intINT
    is_a_largerINT