Nodes/Shima/Shima Int (Math)
ComfyUI Node

Shima Int (Math)

An integer primitive that actually does math

By KDB-USJP·Created 6 months ago·Updated 6 months ago· 2
Shima Int (Math)
  • a
  • b
  • c
  • value
value1
expressiona
allow_external_linkingfalse

Shima Int is a value node with a bonus: besides holding an integer, it can evaluate a small math expression on that value plus up to three wired inputs. If you've ever wanted a single knob that emits batch_size * 2 or steps - 10 without chaining three separate math nodes, this is the node.

The core problem it solves is the boring one every workflow hits - a number that needs to feed several places, and occasionally needs to be derived from other numbers. The KB's node-plumbing doc calls this family "one source, many consumers," and Shima Int is that idea with an expression evaluator bolted on. You type a number into value, optionally feed a, b, and c from other nodes, write an expression using those letters, and the value output is the result.

The bits that matter

  • value - the base integer. Range is a billion either way, so it'll hold any seed or dimension you throw at it. If you leave the expression as the default a and don't wire a, the node just returns value. That's the "plain primitive" mode.
  • expression - where the magic lives. It uses safe evaluation, so you get arithmetic (a * 2, b + c - a, value % 100) without arbitrary code execution. The letters a, b, c map to their input sockets, and value is also in scope.
  • a / b / c - optional INT,FLOAT inputs, wired from other nodes. Unwired, a falls back to value, and b/c fall back to 0. So a * 3 with no wires is literally value * 3.

One subtlety worth knowing: the output is always INT (it floors the float result), so don't use this for ratio math you need to keep precise - that's the float sibling's job. And allow_external_linking is the island-system toggle: on, and this node broadcasts outside its ComfyUI group, which is how you share one derived number across an island without dragging wires everywhere.

Install

Same pack install as always:

cd ComfyUI/custom_nodes
git clone https://github.com/KDB-USJP/shima_wf

then restart ComfyUI, or grab it via ComfyUI Manager → search "Shima". No models needed.

Where people trip

The most common stumble is expecting a to be wired and the fallback to matter - it doesn't; wiring any of a/b/c overrides the fallback. Also, if your expression throws (bad syntax, divide by zero), the node fails at queue time with a safe_eval error, so keep expressions simple. Honestly, if you only need a plain integer source, ComfyUI's own primitive nodes are the lower-dependency option - Shima Int earns its slot when you want that math baked into the same node, or when you're already inside the Shima island system and want the broadcast behavior. For everything else it's a perfectly fine primitive with extra steps.

CategoryShima/Utilities

Inputs (6)

NameTypeDefaultDescription
valueINT1-1000000000–1000000000
expressionSTRINGa
aoptINT,FLOAT0
boptINT,FLOAT0
coptINT,FLOAT0
allow_external_linkingoptBOOLEANfalseIf ON, this node broadcasts/receives OUTSIDE the Island (ignores group regex)

Outputs (1)

NameTypeDescription
valueINT