ComfyUI Node

Logic Compare

Compare two numbers, get the winner — or the average

By HavocsCall·Created 2 years ago·Updated 9 months ago· 4
Logic Compare
  • Number_1
  • Number_2
  • Result Float
  • Result Integer
Operation

Logic Compare takes two numbers and one of three operations - Find Greater, Find Lesser, or Find Average - and hands back the result. It's the pack's attempt at bringing a tiny bit of decision-making into the graph, and it's the kind of node that looks pointless until you need to pick a value between two computed ones.

Why you'd reach for it

ComfyUI graphs are mostly data plumbing, but every so often you want the graph to decide something numeric: the larger of two denoise values, the smaller of two widths, the midpoint of two step counts. That's this node. It's especially handy for clamping or normalizing values computed by math nodes - pick the max of a computed value and a floor so you never feed a sampler something tiny, or average two settings to "split the difference."

It's honest, lightweight logic. There are heavier logic suites out there with full boolean gates and conditionals, but if your need is "compare two numbers and keep going," this is enough, and it comes with no dependency baggage.

How it works

A match on the operation, applied to its two inputs:

case "Find Greater": result = max(Number_1, Number_2)
case "Find Lesser":  result = min(Number_1, Number_2)
case "Find Average": result = (Number_1 + Number_2) / 2

Inputs:

  • Number_1, Number_2 - typed as * (any type), so ComfyUI lets you plug in whatever numeric-ish value you have. That's convenient, but it means there's no type checking at the socket - feed it strings and you'll get a confusing runtime error.
  • Operation - the dropdown: Find Greater, Find Lesser, Find Average.

Outputs - here's the design quirk worth knowing:

  • Result Float - the result as a float.
  • Result Integer - the same result as an int.

You get both, always. The int version is a truncation, not a rounding - same behavior (and same gotcha) as the pack's Float to Integer node.

Where people get burned

The dual outputs are the thing that catches people: this node returns two values that are the same number in different types. If you only need one, just take one - but you can't pick which to compute, both are always produced. Wire only what you need.

The other trap is the * input type. It's a convenience that can bite: plug in a string by mistake and max() or the average math throws a Python error that's hard to read. Keep the inputs numeric, and when in doubt, run them through the pack's conversion nodes first.

Installing it

ComfyUI Manager → search "HavocsCall" → install → restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/HavocsCall/comfyui_HavocsCall_Custom_Nodes

Restart, under HavocsCall/Logic. No requirements.txt, no model downloads - instant.

CategoryHavocsCall/Logic

Inputs (3)

NameTypeDefaultDescription
Number_1*
Number_2*
OperationCOMBO3 options: Find Greater, Find Lesser, Find Average

Outputs (2)

NameTypeDescription
Result FloatFLOAT
Result IntegerINT