GLSL built-in function

intBitsToFloat()

Reinterprets signed integer bits as floating-point.

Demo version: GLSL ES 3.00 / WebGL 2Demo stage: Fragment

Syntax

genType intBitsToFloat(genIType x)

genType means float / vec2 / vec3 / vec4; genIType means int / ivec2 / ivec3 / ivec4; matching placeholders use the same type.

Parameters

x
Input value or left-hand vector

Return value

A float or floating-point vector obtained by reinterpreting the signed integer bit patterns.

Live example

Edit the code and the preview updates as you type.

What intBitsToFloat does

Reinterprets signed integer bits as floating-point.

Read the preview

intBitsToFloat(1065353216) produces 1.0, placing the plotted line at the top edge. Try 1056964608 to decode 0.5 and move the line halfway up the upper half.

Core call

intBitsToFloat(1065353216);

Arbitrary bit patterns may represent NaN or infinity; the demo uses the known 1.0 pattern.

Experiment

Set the argument of intBitsToFloat to 0. All zero bits encode 0.0, so the line moves to the horizontal center and the background takes the midpoint color.

Specification

GLSL ES 3.00 built-in functions, chapter 8

Related functions