M Int Sign
-1, 0, or 1 — direction as a number
- sign
The sign function answers the simplest question in math - "which way is this going?" - and answers it as a number you can wire into anything: -1 for negative, 1 for positive, 0 for exactly zero. M Int Sign takes one integer x and returns sign, one of those three values.
The reason it's useful in a graph, not just in your head, is that it turns a direction into a value that arithmetic can use:
- Direction-aware scaling.
sign * magnitudegives you a signed value from a direction and a size computed separately. Multiply a strength by the sign of a difference and you get "push it the way the data says." - Classifying values. Instead of comparing a value against zero with a conditional,
signgives you a 1/0/-1 you can feed straight into a switch selector or multiply into a branch. - Stable sign for math. When you want the sign of something without its magnitude - "is this delta positive or negative" - sign is the primitive that comparison nodes build on.
Mechanically it's a three-way branch: 0 if zero, 1 if positive, -1 if negative. Input is signed 32-bit INT, default 0. It's the third of the pack's unary trio with M Int Abs and M Int Neg, and it composes with the comparison nodes to build conditionals out of pure arithmetic.
It ships in ComfyUiNodes (repo Madlumi/ComfyUiNodes, author "Madanie"), a small personal pack of integer math, string helpers, and workflow-glue nodes. Install via ComfyUI Manager - search "ComfyUiNodes" - or:
cd ComfyUI/custom_nodes
git clone https://github.com/Madlumi/ComfyUiNodes
Restart ComfyUI afterward. No pip requirements or model downloads. It's under Add Node → mnodes → int.
Honest note: sign is niche - you'll reach for the comparison nodes before it most of the time. But the day you want "which direction is this value moving," it's the only node that hands it to you as a number.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| x | INT | 0-2147483648–2147483647 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| sign | INT | — |