Intrinsics1 min read
asint
Reinterprets bits as signed integers.
Reading Time
1 min
Word Count
98
Sections
7
Try It Live
Test asint in a live shader
Open the playground, start from a visual preset, and wire asint into the fragment stage to see how it behaves with real values.
Open PlaygroundThe asint function reinterprets a value's bit pattern as a signed integer. It is commonly used to inspect floating-point sign, exponent, or mantissa bits.
Live Demo
Signature
bwsl
asint :: (float x) -> int
asint :: (uint x) -> int
asint :: (floatN x) -> intN
asint :: (uintN x) -> intN
Parameters
| Parameter | Type | Description |
|---|---|---|
x | float, uint, or vector form | Source bits to reinterpret |
Return Value
Returns an int or intN with the same bits as x.
Example
bwsl
float value = -2.0;
int bits = asint(value);Compiled Output
When compiled to GLSL:
glsl
floatBitsToInt(x)
When compiled to HLSL:
hlsl
asint(x)
When compiled to Metal:
metal
as_type<int>(x)
See Also
- asfloat - Reinterpret bits as floats
- asuint - Reinterpret bits as unsigned integers
- count_bits - Count set bits