LayerUtility: Number Calculator V2
Number Calculator V2
- a
- b
- int
- float
- string
Number Calculator V2 is a small, unglamorous, and genuinely handy node: it does math on two numbers inside your graph. Multiply a width by 1.5, subtract a padding value, take the max of two sizes, compute an nth root - anything where you need one number derived from others instead of typed by hand. In a workflow that has to stay consistent when dimensions change, this is the node that does the arithmetic so you don't hardcode a magic number that breaks the moment you resize.
It's an "a operator b" calculator. The inputs:
- a_value / b_value - the two operands, entered as text fields. You can type literal numbers here.
- a / b - optional wildcard inputs. This is the important part: instead of typing values, you can wire numbers in from other nodes (an image's width, a slider, another calculator's output). When connected, these feed the operands, which is what makes the node useful in an automated graph rather than as a pocket calculator.
- operator - the operation, from ten choices:
+,-,*,/,**(power),//(floor divide),%(modulo),nth_root,min,max. So it goes well beyond basic arithmetic - powers, roots, and min/max are all there.
It gives you three outputs of the same result in different types: int, float, and string. That's a nice touch - some downstream nodes want an integer (image dimensions, step counts), some want a float, some want text for a filename or label. You just grab the output type the next node expects, no conversion node needed.
Where it fits: any graph with derived numbers. Computing a target resolution from a base size and a scale factor, keeping an aspect ratio when one dimension changes, deriving latent sizes, building dynamic values for a batch. The min/max operators are quietly useful for clamping - "don't let this exceed 1024" is a min away. It's the kind of node you don't think about until you need it, and then you're glad it exists instead of having to hardcode and re-edit numbers by hand every time an input changes.
This is one of a family of graph-utility nodes - the same "make a workflow too large to read into one you can still work in" space that rgthree and WAS Node Suite live in. Number Calculator is a leaf of that: pure logic, no image processing, no models. Nothing to break, nothing to download.
Install is the pack standard. Easiest is ComfyUI Manager - search ComfyUI Layer Style (or "LayerStyle"), install, restart. Manual: cd ComfyUI/custom_nodes && git clone https://github.com/chflame163/ComfyUI_LayerStyle, then pip install -r requirements.txt from inside the folder using ComfyUI's Python, and restart. On a hosted ComfyUI it's usually preinstalled.
The pack-wide caveat: Layer Style is well known for import failures - install it, restart, and the whole node set shows up red or missing. It's rarely the individual node; it's a dependency clash. The pack pulls a heavy stack (transformers, onnxruntime, opencv), and one mismatched version - a stray transformers or tensorflow being the usual culprit - takes the entire pack down on import. Fix it by reading the ComfyUI startup log for the traceback (it names the package that failed), reinstalling requirements against ComfyUI's own Python, and using Manager's Try Fix. If Number Calculator is missing, so is every other LayerStyle node, and that shared import failure is the real thing to fix - a bit ironic for a node whose only dependency is arithmetic, but it goes down with the pack all the same.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| a_value | STRING | — | |
| b_value | STRING | — | |
| operator | COMBO | 10 options: +, -, *, /, **, //, +4 | |
| aopt | * | — | |
| bopt | * | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| int | INT | — |
| float | FLOAT | — |
| string | STRING | — |