Bit Reinterpret Helpers

The Bit Reinterpret Helpers allow scripts to inspect the raw bit-pattern of numeric values by converting them into a uint32.

These functions do not convert or scale values — they reinterpret the raw memory bits of the input


uint32 f_to_u32(float f)

Returns the raw 32-bit IEEE-754 representation of a float.

uint32 bits = f_to_u32(1.0f);     // 0x3F800000

uint32 u8_to_u32(uint8 v)

Reinterprets a uint8 as a uint32.

uint32 bits = u8_to_u32(255);     // 0x000000FF

uint32 u16_to_u32(uint16 v)

Reinterprets the lower 16 bits of a uint16 as a 32-bit integer.

uint32 bits = u16_to_u32(50000);

uint32 u64_to_u32(uint64 v)

Returns the lower 32 bits of a 64-bit unsigned integer.

uint32 bits = u64_to_u32(0x1122334455667788);

uint32 i8_to_u32(int8 v)

Reinterprets a signed 8-bit integer as a 32-bit unsigned integer.


uint32 i16_to_u32(int16 v)

Reinterprets a signed 16-bit integer as 32 bits.


uint32 i32_to_u32(int32 v)

Reinterprets a signed 32-bit integer as an unsigned one without numerical conversion.


uint32 i64_to_u32(int64 v)

Returns the lower 32 bits of a 64-bit signed integer.


uint32 d_to_u32(double v)

Returns the first 4 bytes of a 64-bit double (the lower half of the binary representation).


float bits_to_float(uint raw)

Reinterprets a 32-bit unsigned integer as an IEEE-754 float.


double bits_to_double(uint64 raw)

Reinterprets a 64-bit unsigned integer as an IEEE-754 double.


uint float_to_bits(float value)

Returns the exact 32-bit IEEE-754 bit pattern of a float.


uint64 double_to_bits(double value)

Returns the exact 64-bit IEEE-754 bit pattern of a double.


float u32_to_f(uint raw)

Convenience alias for bits_to_float(raw).

Last updated