Nodes/ComfyUI-Light-Tool/Light-Tool: Calculate
ComfyUI Node

Light-Tool: Calculate

Arithmetic inside your graph — all three output types at once

By ihmily·Created 2 years ago·Updated 4 months ago· 20
Light-Tool: Calculate
  • number1
  • number2
  • result_string
  • result_int
  • result_float
operator+
description

Light-Tool: Calculate is a two-number calculator that lives in your graph: pick an operator, feed it two numbers, and get the result out as a string, an integer, and a float - simultaneously. ComfyUI's biggest quality-of-life gap for people building dynamic workflows is doing math on the fly, and this node plugs that hole with zero fuss.

Where it shines is computed values. "My image is 1024 wide, so half of it for the preview is…" - instead of computing by hand and hard-coding, you wire the width into this node, set / 2, and read the result. Change the source width later and the whole graph updates. Same for latents sizing, tiling math, or scaling weights derived from another value.

How it works

You give it number1, number2, and an operator from +, -, *, /, % (addition, subtraction, multiplication, division, modulo). Both operands are parsed as numbers - it accepts numeric strings as well as actual numbers, so it plays nicely with text outputs from other nodes. Then it does the arithmetic and returns the result in all three forms:

  • result_string - the plain text version ("3.5")
  • result_int - rounded to a whole number (4)
  • result_float - full precision (3.5)

Having all three is genuinely thoughtful, because different downstream nodes demand different types. Wire the int into anything that wants a dimension, the float into a weight or scale input, the string into a text display - no conversion step needed.

There's also an optional description multiline field, purely for your own labeling - it doesn't affect the math, just helps you remember what the node is doing when you revisit the workflow in three weeks.

The hard stops

Division and modulo by zero are hard errors - the node raises rather than returning a silent infinity or NaN. And if either input isn't actually a number, you get a clear error telling you so. Both are the right behavior; failing loudly beats baking a broken value into the graph. If your operands might legitimately be zero (a divider you can't control), guard the value before it gets here.

Where it fits

This is the pack's answer to "do I really need a full math pack for this?" For a single operation, yes - this is lighter than pulling in a dedicated math toolkit, and it reads cleanly in a graph. Chain two of them for anything multi-step, or reach for a proper math node collection once you need trig, logs, or complex expressions. For the 90% case - add, subtract, multiply, divide - this is the one you'll actually keep in your favorites.

Install

Standard: ComfyUI Manager → search ComfyUI-Light-Tool, or clone into custom_nodes, pip install -r requirements.txt, restart. It's under ComfyUI-Light-Tool → DataProcessing. Pure Python, no models, no network.

CategoryComfyUI-Light-Tool/DataProcessing

Inputs (4)

NameTypeDefaultDescription
number1*1.0
number2*1.0
operatorCOMBO+5 options: +, -, *, /, %
descriptionoptSTRING

Outputs (3)

NameTypeDescription
result_stringSTRING
result_intINT
result_floatFLOAT