Nodes/ComfyUI-Basic-Math/Number In Range | Basic
ComfyUI Node

Number In Range | Basic

One boolean that answers 'is this number in the window?'

By akatz-ai·Created about a year ago·Updated 11 months ago· 16
Number In Range | Basic
  • value
  • min_value
  • max_value
  • BOOLEAN
inclusivetrue

Comparing one number to another gives you half the picture. Sometimes what you actually want is "is this value between these two?" - a band, not a boundary. NumberInRange ("Number In Range | Basic") is the node that answers that in a single boolean: give it value, min_value, and max_value, and it tells you whether the value sits inside the range.

The mechanism is a pair of comparisons combined. With the inclusive flag on (the default), it checks min_value <= value <= max_value. Flip inclusive off and it becomes min_value < value < max_value - the endpoints themselves no longer count as "in range." All three number inputs accept INT or FLOAT thanks to the pack's NUMBER union type; the output is a BOOLEAN.

The inputs that matter

  • value - the number you're testing.
  • min_value, max_value - the window (defaults 0 and 1).
  • inclusive - whether the boundaries count. This is the one to remember: it's the difference between accepting exactly 1.0 or rejecting it.

Why you'd reach for it

This is the threshold-band node, and it shows up wherever a single comparison isn't enough. Guard rails: "only run this branch when the denoise is between 0.4 and 0.7." Validation: "reject any width outside the model's native range." Loop control: "proceed while the step counter is below N." The alternative is two NumberComparison nodes plus a BooleanLogic AND - which works, but takes three nodes and twice the wiring to say the same thing.

There's a subtlety with inclusive that's easy to miss and worth internalizing. The exclusive mode (min < value < max) is the one you want when a value that lands exactly on a boundary shouldn't trigger the branch - say, an edge case you want to leave unhandled. For almost everything else, the default inclusive behavior is right.

Installing it

Standard pack install - pure Python, zero dependencies:

cd ComfyUI/custom_nodes
git clone https://github.com/akatz-ai/ComfyUI-Basic-Math

Restart ComfyUI, find it under Basic Math ➕ → Utility. Or use ComfyUI Manager → Install Custom Nodes → search "ComfyUI-Basic-Math".

The gotchas

If min_value is above max_value, the node simply returns false for everything - there's no swapping, so keep your bounds ordered. And remember the output is a strict boolean, so it plugs into switches and BooleanLogic directly. Also, the menu name carries the pack's | Basic suffix, so look for "Number In Range | Basic" - not a different node, just this pack's naming convention.

CategoryBasic Math ➕/Utility

Inputs (4)

NameTypeDefaultDescription
valueINT,FLOAT0
min_valueINT,FLOAT0
max_valueINT,FLOAT1
inclusiveBOOLEANtrue

Outputs (1)

NameTypeDescription
BOOLEANBOOLEAN