Intrinsics1 min read

isnormal

Componentwise test for normal finite floating-point values.

Reading Time
1 min
Word Count
97
Sections
7
Try It Live

Test isnormal in a live shader

Open the playground, start from a visual preset, and wire isnormal into the fragment stage to see how it behaves with real values.

Open Playground

The isnormal function returns true for finite floating-point values that are neither zero nor subnormal.

Live Demo

Signature

bwsl
isnormal :: (float x) -> bool
isnormal :: (float2 x) -> bool2
isnormal :: (float3 x) -> bool3
isnormal :: (float4 x) -> bool4

Parameters

ParameterTypeDescription
xfloat, float2, float3, float4Value(s) to classify

Return Value

Returns a bool or boolN where each component is true when the corresponding input is finite and normal.

Example

bwsl
float scale = length(gradient);
if (!isnormal(scale)) {
scale = 0.0;
}

Zeros Are Not Normal

isnormal(0.0) returns false. Use isfinite when zero is an acceptable value.

Compiled Output

When compiled to GLSL:

glsl
isnormal(x)

When compiled to HLSL:

hlsl
isnormal(x)

When compiled to Metal:

metal
isnormal(x)

See Also