Nodes/ComfyUI Layer Style/LayerUtility: Number Calculator
ComfyUI Node Runs on cloud

LayerUtility: Number Calculator

Number Calculator (Layer Style)

By chflame163·Created 3 years ago·Updated 4 days ago· 3,113
LayerUtility: Number Calculator
  • a
  • b
  • int
  • float
◄operator▾►

Number Calculator is the node you drop in when you need to do arithmetic on values already flowing through your workflow instead of hardcoding a number. Multiply a width by a scale factor, subtract a border, compute steps from a slider - anything where the number should be derived rather than typed. It's a tiny thing, but math nodes are the glue that lets a workflow adapt to its inputs instead of assuming them.

Under the hood it takes two numbers, applies an operator, and returns the result. What makes it convenient is that it hands you the answer in both integer and float form, so you don't have to bolt a converter on afterward.

There are only three inputs and all three matter. a and b are wildcard ports (*), so they happily take ints or floats coming from other nodes - image dimensions, seeds, whatever. The operator dropdown is the real control, with ten options:

  • The basics - +, -, *, /
  • Powers and integer math - ** (exponent), // (floor division), % (modulo), nth_root
  • min / max - pick the smaller or larger of the two

The two outputs are int and float. Same computed value, two types. Wire int into anything expecting a whole number (dimensions, step counts, batch sizes - most ComfyUI size fields want ints) and float wherever a decimal is fine (a denoise value, a scale multiplier). Handing you both is a genuinely nice touch, because ComfyUI is picky about number types and this saves you a cast.

The practical wins: computing a target resolution from an input's dimensions (multiply height by 1.5, feed int to an upscaler), keeping an aspect ratio locked, deriving a crop margin as a percentage of the width, or figuring out how many tiles you need. Chain a few together with Boolean Operator and you can build workflows that size themselves.

To get it, install the whole ComfyUI Layer Style pack - this node ships inside it. Easiest path is ComfyUI Manager: search "ComfyUI Layer Style," install, restart. Manual path: cd ComfyUI/custom_nodes && git clone https://github.com/chflame163/ComfyUI_LayerStyle, then pip install -r requirements.txt in your ComfyUI environment and restart. No model download - it's arithmetic.

One thing to watch that's specific to this node: division. / by zero and some nth_root edge cases can throw, and floor-division/modulo semantics on floats can surprise you if you're expecting Python-int behavior, so sanity-check the output when you first wire it. Beyond that, the usual pack-level caveat applies - Layer Style is a big pack with a lot of Python dependencies, and its single most common failure is the entire pack refusing to import (you'll see "import failed" in the Manager, usually a transformers version clash), which makes every node in it vanish at once, this one included. If Number Calculator simply isn't in your list, that's the reason, not a missing node - reinstall the pack or use the Manager's "Try Fix," and reinstall the requirements into ComfyUI's actual Python env if it persists.

Category😺dzNodes/LayerUtility/Data

Inputs (3)

NameTypeDefaultDescription
a*—
b*—
operatorCOMBO10 options: +, -, *, /, **, //, +4

Outputs (2)

NameTypeDescription
intINT—
floatFLOAT—