CDX Numeric Utilities

Contents

Typedefs

Typedef Description
bool8_t 8-bit boolean type.
real32_t Ginmake-facing IEEE-754 binary32 scalar.
real64_t Ginmake-facing IEEE-754 binary64 scalar.

Functions

Function Description
CDX_byteswap16 Reverse the byte order of a 16-bit integer.
CDX_byteswap32 Reverse the byte order of a 32-bit integer.
CDX_byteswap64 Reverse the byte order of a 64-bit integer.
CDX_reinterpret_cast_u32 Return the IEEE-754 binary32 representation of a float.
CDX_reinterpret_cast_u64 Return the IEEE-754 binary64 representation of a double.
CDX_reinterpret_cast_f32 Interpret an unsigned 32-bit integer as IEEE-754 binary32 bits.
CDX_reinterpret_cast_f64 Interpret an unsigned 64-bit integer as IEEE-754 binary64 bits.
CDX_sign_extend_u8 Sign-extend a raw signal to an 8-bit signed integer.
CDX_sign_extend_u16 Sign-extend a raw signal to a 16-bit signed integer.
CDX_sign_extend_u32 Sign-extend a raw signal to a 32-bit signed integer.
CDX_sign_extend_u64 Sign-extend a raw signal to a 64-bit signed integer.
CDX_f32_rounds_to_zero Test whether rounding to the nearest integer gives zero.

Typedefs

bool8_t

8-bit boolean type.

1typedef uint8_t bool8_t

real32_t

Ginmake-facing IEEE-754 binary32 scalar.

1typedef float real32_t

real64_t

Ginmake-facing IEEE-754 binary64 scalar.

1typedef double real64_t

Functions

CDX_byteswap16

Reverse the byte order of a 16-bit integer.

1uint16_t CDX_byteswap16(uint16_t value)

Returns

Integer with its bytes reversed.

Parameters

  • uint16_t value: Integer to convert.

Location: cdx_utils.h:50

CDX_byteswap32

Reverse the byte order of a 32-bit integer.

1uint32_t CDX_byteswap32(uint32_t value)

Returns

Integer with its bytes reversed.

Parameters

  • uint32_t value: Integer to convert.

Location: cdx_utils.h:58

CDX_byteswap64

Reverse the byte order of a 64-bit integer.

1uint64_t CDX_byteswap64(uint64_t value)

Returns

Integer with its bytes reversed.

Parameters

  • uint64_t value: Integer to convert.

Location: cdx_utils.h:67

CDX_reinterpret_cast_u32

Return the IEEE-754 binary32 representation of a float.

1uint32_t CDX_reinterpret_cast_u32(float value)

Returns

The same bit pattern as an unsigned 32-bit integer.

Parameters

  • float value: Floating-point value; no numeric conversion is performed.

Location: cdx_utils.h:76

CDX_reinterpret_cast_u64

Return the IEEE-754 binary64 representation of a double.

1uint64_t CDX_reinterpret_cast_u64(double value)

Returns

The same bit pattern as an unsigned 64-bit integer.

Parameters

  • double value: Floating-point value; no numeric conversion is performed.

Location: cdx_utils.h:86

CDX_reinterpret_cast_f32

Interpret an unsigned 32-bit integer as IEEE-754 binary32 bits.

1float CDX_reinterpret_cast_f32(uint32_t value)

Returns

The float with that bit pattern, including NaNs and infinities.

Parameters

  • uint32_t value: Bit pattern; no numeric conversion is performed.

Location: cdx_utils.h:96

CDX_reinterpret_cast_f64

Interpret an unsigned 64-bit integer as IEEE-754 binary64 bits.

1double CDX_reinterpret_cast_f64(uint64_t value)

Returns

The double with that bit pattern, including NaNs and infinities.

Parameters

  • uint64_t value: Bit pattern; no numeric conversion is performed.

Location: cdx_utils.h:106

CDX_sign_extend_u8

Sign-extend a raw signal to an 8-bit signed integer.

1int8_t CDX_sign_extend_u8(uint8_t bits, uint8_t value)

Returns

Signed value using the selected width’s most significant bit as sign.

Parameters

  • uint8_t bits: Signal width; zero returns zero, widths above 8 are clamped to 8.
  • uint8_t value: Raw signal; bits above the selected width are discarded.

Location: cdx_utils.h:121

CDX_sign_extend_u16

Sign-extend a raw signal to a 16-bit signed integer.

1int16_t CDX_sign_extend_u16(uint8_t bits, uint16_t value)

Returns

Signed value using the selected width’s most significant bit as sign.

Parameters

  • uint8_t bits: Signal width; zero returns zero, widths above 16 are clamped to 16.
  • uint16_t value: Raw signal; bits above the selected width are discarded.

Location: cdx_utils.h:128

CDX_sign_extend_u32

Sign-extend a raw signal to a 32-bit signed integer.

1int32_t CDX_sign_extend_u32(uint8_t bits, uint32_t value)

Returns

Signed value using the selected width’s most significant bit as sign.

Parameters

  • uint8_t bits: Signal width; zero returns zero, widths above 32 are clamped to 32.
  • uint32_t value: Raw signal; bits above the selected width are discarded.

Location: cdx_utils.h:135

CDX_sign_extend_u64

Sign-extend a raw signal to a 64-bit signed integer.

1int64_t CDX_sign_extend_u64(uint8_t bits, uint64_t value)

Returns

Signed value using the selected width’s most significant bit as sign.

Parameters

  • uint8_t bits: Signal width; zero returns zero, widths above 64 are clamped to 64.
  • uint64_t value: Raw signal; bits above the selected width are discarded.

Location: cdx_utils.h:142

CDX_f32_rounds_to_zero

Test whether rounding to the nearest integer gives zero.

1uint8_t CDX_f32_rounds_to_zero(float value)

Returns

Nonzero only for -0.5 < value < 0.5; false for NaN and either boundary.

Note: Half-way values are treated as rounding away from zero.

Parameters

  • float value: Floating-point value to test.

Location: cdx_utils.h:149