Nodes/ComfyUI-JDCN/LogicUtil_Power
ComfyUI Node

LogicUtil_Power

Exponent math with a guardrail that occasionally bites

By daxcay·Created 2 years ago·Updated about a year ago· 159
LogicUtil_Power
  • input1
  • power
  • *

Need x raised to a power in the middle of a workflow? LogicUtil_Power is the node: input1 raised to power, one value out. It's math.pow(input1, power) under the hood, which sounds like the last node that needs a warning label - and then you read the source and find one.

How it works

The guardrail: before computing, the node checks the magnitude of the result and raises an OverflowError if the exponent would produce a number with more than ~100 digits. That's a sensible safety net against accidentally typing 2 and 1000 and getting an infinite loop of giant-number handling. The problem is the check has a quirk: it computes log10(abs(input1)) to estimate magnitude, and if that log is zero - meaning input1 is exactly 1 or -1 - it throws the overflow error anyway. So math.pow(1, 500) - which is trivially 1, no overflow anywhere - gets refused. Raise 1 to a big power and the node will tell you your exponent is "too large." It's a bug-shaped behavior, and knowing it saves you a confused evening.

Two more constraints come from using math.pow rather than Python's **:

  • input1 = 0 throws a domain error, because you can't take a log of zero even when the actual power would be fine.
  • A negative base with a fractional power ((-4) ** 0.5) is a math-domain error - no real-number answer exists, and the node doesn't fake one with complex numbers.

In practice that means: keep bases positive, keep exponents reasonable, and don't power a literal 1 and blame the node when it yells at you. If you need integer-only powering with wild exponents, a plain formula-style math node is the more forgiving tool.

Where it earns its place: brightness/contrast curves (raise a normalized value to a gamma), easing curves for animation, and any scaling that's fundamentally exponential rather than linear. Paired with LogicUtil_Multiply and a Min/Max clamp, you can build a surprisingly capable curve generator out of two nodes. It's part of the LogicUtil family - a port of aria1th's ComfyUI-LogicUtils riding inside the JDCN pack, whose README documents the file and latent batch nodes and never mentions this family.

Install

Install is the standard JDCN routine: ComfyUI Manager → "Install Custom Node" → search JDCN → install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/daxcay/ComfyUI-JDCN
cd ComfyUI-JDCN && pip install -r requirements.txt

Only piexif on the requirements list, no models to fetch. And when Power throws "too large" on something that obviously isn't, check whether your base is 1 - the guardrail is doing its best, it's just bad at math trivia.

CategoryLogicUtil

Inputs (2)

NameTypeDefaultDescription
input1*
power*

Outputs (1)

NameTypeDescription
**