Nodes/FxAi(凤希全能节点)/凤希AI - 整数运算
ComfyUI Node

凤希AI - 整数运算

Index + 1, and the other arithmetic your graph can't do without

By fxai666·Created 7 months ago·Updated about 20 hours ago· 47
凤希AI - 整数运算
    • INT
    ◄a0►
    ◄b0►
    ◄operationadd►

    The least interesting node you'll use most

    ComfyUI will do a lot of things, but it won't add two numbers. There's no + socket. So the moment a workflow needs "half the width", "the index plus one", or "batch size times three", you're reaching for a math node, and this pack's entry is FxAiMathInt (凤希AI - 整数运算).

    It's two typed-in integers, an operation dropdown, and one INT out. Six operations: add, subtract, multiply, divide, modulo, power.

    How it works

    A dictionary of six lambdas. That's the implementation. The one worth reading about is divide:

    "divide": lambda a, b: a // b,
    

    That's Python floor division, not true division - and the author put it in the tooltip because it catches people. 7 / 2 here is 3, and -7 / 2 is -4, because floor goes down, not toward zero. If you wanted 3.5 you're in the wrong node; that's FxAiSimpleMath, whose float output doesn't round.

    The rest behave exactly as you'd expect (modulo is %, power is **), and the range on a and b is effectively unbounded for workflow purposes - 64-bit worth.

    Inputs and outputs

    • a (INT, default 0)
    • b (INT, default 0)
    • operation (dropdown, default add)

    Output: a single INT.

    Both inputs can be typed in or wired. The most common wiring is index from a loop start node into a, with b set to 1 - which is exactly what this pack's own for-loop does internally to advance its counter. Once you know that, FxAiMathInt stops looking like a placeholder node and starts looking like the loop's gearbox.

    Other reliable uses: dividing a target width by 2 before a resize; converting a total frame count into a segment count; offsetting an index by a starting point (起始帧 + index × 段长 territory); stepping a seed by a constant so each iteration of a loop gets a different but reproducible noise start.

    The INT trap

    Everything here is integer in, integer out, and that has two sharp edges.

    Divide by zero raises. There's an explicit guard that throws 除数为 0 with a readable message rather than letting Python's ZeroDivisionError bubble up. Good, but it's still a hard failure mid-run - if b comes off a wire, make sure it can't be zero. That's what FxAiIfElse and FxAiCompare are for.

    power with a negative exponent returns a float. 2 ** -1 is 0.5, but the node declares its output as INT. You'll get the float through, and then something downstream that genuinely wants an integer will complain in a place that has nothing to do with this node. Keep b non-negative on power and use the formula node for anything that has to be fractional.

    Installing

    cd ComfyUI/custom_nodes
    git clone https://github.com/fxai666/fxai-toolkit
    

    Restart, or search fxai-toolkit in ComfyUI Manager (registry publisher fxai). The pack pip-installs soundfile and psutil when it first loads. No models, no extra dependencies for this one - it's one of the lightest things in a pack that also ships a SeedVR2 pipeline.

    Where it bites

    It only does integers. Feed a float into a and it either gets rejected or truncated depending on how the link is typed; either way you're losing information. Formula work belongs in FxAiSimpleMath with its int/float/boolean triple output.

    Rounding is free, and that's the problem. A width of 1001 divided by 2 gives you 500, and then a VAE that wants multiples of 8 quietly does something you didn't ask for. Do the arithmetic with the target's constraints in mind, not just the number.

    Node not in the menu. Every node in this pack is imported individually and wrapped in try/except, logging ❌[凤希AI] 节点加载失败 to the console on failure - so a missing node means a failed import somewhere, not a bad install. Console first, then restart.

    Category凤希AI/逻辑

    Inputs (3)

    NameTypeDefaultDescription
    aINT0-18446744073709550000–18446744073709550000—
    bINT0-18446744073709550000–18446744073709550000—
    operationCOMBOadddivide 是整除(向下取整),跟 Python // 一致。

    Outputs (1)

    NameTypeDescription
    INTINT—