Nodes/ComfyUI-JakeUpgrade/Float Binary Operation JK๐Ÿ‰
ComfyUI Node

Float Binary Operation JK๐Ÿ‰

Do real math on your floats without a calculator node

By jakechaiยทCreated 2 years agoยทUpdated 3 months agoยท 146
Float Binary Operation JK๐Ÿ‰
    • FLOAT
    โ—„opโ–พโ–บ
    โ—„a0.00โ–บ
    โ—„b0.00โ–บ

    Every interesting workflow eventually needs to compute a number: a denoise strength that's a fraction of the steps, an upscale factor, an aspect-ratio-corrected dimension. Float Binary Operation JK is the two-input calculator for that. Pick an operation, feed it two floats, get one float back. Nothing fancy, but it's the workhorse that keeps you from hardcoding values into every sampler.

    How it works

    You pick an op from a dropdown and supply a and b. The operations are straightforward math: Add, Sub, Mul, Div, Mod, Pow, FloorDiv, Max, Min, Log, Atan2. It applies the selected one and returns the result.

    Two gotchas live in the dropdown:

    • Log is log base b of a, not natural log. op=Log, a=100, b=10 gives you 2.
    • Div by zero throws an error rather than returning infinity. The node raises a ValueError with a message naming the operation and the offending values, so you'll see exactly where the graph broke. It's a deliberate choice - silent inf flows are how you get garbage downstream and spend an hour hunting it.

    Inputs and outputs

    • op - the operation dropdown.
    • a - first float.
    • b - second float.
    • FLOAT - the single output.

    The classic patterns: Mul a base resolution by a scale factor, Div to split a budget across passes, Min to clamp an aggressive number against a sane ceiling. Because the output is typed FLOAT, you'll usually run it into Float To Int JK before feeding latent dimensions or steps.

    Installing it

    Ships in ComfyUI-JakeUpgrade:

    • ComfyUI Manager โ†’ search "JakeUpgrade" โ†’ install โ†’ restart.
    • Or:
    cd ComfyUI/custom_nodes
    git clone https://github.com/jakechai/ComfyUI-JakeUpgrade
    cd ComfyUI-JakeUpgrade
    pip install -r requirements.txt
    

    Windows portable: run install.bat or ../../../python_embeded/python.exe -s -m pip install -r requirements.txt.

    Common issues

    • Division by zero kills the run. If b can be zero at runtime (say it comes from an unconnected or empty input), the node errors. Guard it with a Max of b against a tiny epsilon, or clamp the input upstream.
    • Operation names aren't obvious for the exotic ones. FloorDiv is integer floor division (useful for chunking), Atan2 is the two-argument arctangent (mainly if you're doing angle math). If you're not doing angle math, you'll live in Add/Mul/Div/Min/Max 95% of the time.

    It's not a replacement for a full math suite - no trig on single values beyond Atan2, no variable storage. But as a drop-in calculator node that shares a pack with JakeUpgrade's parameters and switch nodes, it keeps your numbers computed instead of typed, which is exactly what a maintainable workflow wants.

    Category๐Ÿ‰ JK/โœ–๏ธ Math/๐Ÿฅ Float

    Inputs (3)

    NameTypeDefaultDescription
    opCOMBOSelect binary mathematical operation
    aFLOAT0.00First float input
    bFLOAT0.00Second float input

    Outputs (1)

    NameTypeDescription
    FLOATFLOATโ€”