Intrinsics1 min read
ldexp
Multiplies a floating-point value by a power of two.
Reading Time
1 min
Word Count
97
Sections
7
Try It Live
Test ldexp in a live shader
Open the playground, start from a visual preset, and wire ldexp into the fragment stage to see how it behaves with real values.
Open PlaygroundThe ldexp function returns x * 2^e, applying an integer exponent directly to a floating-point significand. It is useful with frexp, custom encodings, and scale factors that are naturally powers of two.
Live Demo
Signature
bwsl
ldexp :: (float x, int e) -> float
Parameters
| Parameter | Type | Description |
|---|---|---|
x | float | Floating-point value to scale |
e | int | Power-of-two exponent |
Return Value
Returns x * exp2(float(e)).
Example
bwsl
BwslFrexpResult parts = frexp(value);
float reconstructed = ldexp(parts.mantissa, parts.exponent);Compiled Output
When compiled to SPIR-V:
spirv
GLSL.std.450 Ldexp
When compiled to GLSL ES:
glsl
x * exp2(float(e))