ComfyUI Node

Number Sign

Negative, zero, or positive — tell in one node

By DebugPadawan·Created about a year ago·Updated 5 months ago· 2
Number Sign
    • sign
    • sign_text
    value0.00

    Sometimes you don't need the number, just the direction. Number Sign looks at a value and tells you which of three buckets it falls into: negative, zero, or positive. That's it - and it's exactly the kind of tiny building block that makes conditional logic readable when you'd otherwise be comparing values against zero and chasing edge cases.

    It's part of DebugPadawan's ComfyUI Essentials, a pure-Python utility pack. This node is a three-way if in a box.

    How it works

    One required input:

    • value - the number to classify (FLOAT, default 0)

    Two outputs:

    • sign - an INT: -1 for negative, 0 for zero, 1 for positive
    • sign_text - the same answer as a STRING: "negative", "zero", or "positive"

    The implementation is exactly that: value > 0 gives (1, "positive"), value < 0 gives (-1, "negative"), and anything else (including exactly 0.0) gives (0, "zero"). No tolerance, no rounding - strict comparison.

    When it earns its place

    • Direction checks. If a computed delta between two values went negative, you know the trend direction without caring about the magnitude. Feed sign into a Number Compare or a Logic Gate and branch on the direction.
    • Sanity checks. Before a node that chokes on negatives, check the sign and route to a Number Abs or a clamp if it's -1.
    • Readable debugging. sign_text gives you "positive" in a log instead of a bare number - small thing, but it makes Debug Print output much friendlier when you're auditing a complex graph.

    Because the output is an INT (-1/0/1), you can also use it directly as a multiplier - flip a direction, toggle a sign - without a comparison step. That's a neat trick for animation or math pipelines: multiply by sign to apply or reverse a value.

    Installing it

    Same story as every node in the pack - one install, all nodes. ComfyUI Manager, searching for "DebugPadawans-ComfyUI-Essentials," or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/DebugPadawan/DebugPadawans-ComfyUI-Essentials
    

    Then restart ComfyUI. Requirements (numpy, torch, opencv-python) are already satisfied by stock ComfyUI; no models to download. Beware the name collision when searching: this is DebugPadawan's ComfyUI Essentials, not cubiq's "ComfyUI Essentials," which is a different pack now in maintenance mode.

    Gotchas

    • Zero is exact. -0.0 and 0.0 both classify as zero. A value like 1e-12 counts as positive, not zero - there's no epsilon here, unlike the pack's Number Compare which builds tolerance into its equal check.
    • The INT output is small but if you expected a boolean you'll need to adapt - sign of -1 is truthy in Python, so branch carefully.
    • It's a small, quiet pack; there's no big community writeup for this node, because there's not much to write. That's the point.
    CategoryDebugPadawan/Number

    Inputs (1)

    NameTypeDefaultDescription
    valueFLOAT0.00

    Outputs (2)

    NameTypeDescription
    signINT
    sign_textSTRING