Build with this node

Start with a prompt in Studio, or copy it into your own coding agent.

Ask Studio

@maruaudio/dsp/math/float-clamp reproduces DaisySP's fclamp, the fmin(fmax(value, minimum), maximum) clamp the CHOMPI firmware uses. Operands are rounded to f32 first. Unlike Math.min/Math.max, C's fmax and fmin ignore a NaN operand, so a NaN value clamps to minimum and a NaN bound is skipped. Ties follow newlib's fmaxf/fminf (x > y ? x : y): the second operand wins, which decides signed zero.

Functions

NameInputsOutputDomain as coded
floatMaxx, yNaN-ignoring maximumA NaN operand returns the other one; ties return y
floatMinx, yNaN-ignoring minimumA NaN operand returns the other one; ties return y
floatClampvalue, minimum, maximumfloatMin(floatMax(f32(value), f32(minimum)), f32(maximum))NaN value → minimum; reversed bounds → maximum

Lifecycle

None. Stateless functions with no preparation or instance state.

When to use it

Ports of DaisySP or CHOMPI code whose output must match the firmware bit for bit. For ordinary Maru parameters use @maru/math-range, whose clamp propagates NaN instead.

Limits

  • f32 operands: floatClamp(1 / 3, 0, 1) returns Math.fround(1 / 3). floatMax and floatMin themselves do not round.
  • The bounds are not reordered; a reversed pair yields maximum.

Algorithm properties and proofs

No Lean 4 proof is mapped to this node.

Explore proofs alongside performance

Dependencies

None: this node imports no other node.

Dependents

Used by