Skip to content

TypeConversion

Overview

Converts between numeric data types

Discussion

This module converts between various 32-bit and 16-bit data types. The input dataType is inherited from the input wire. The output dataType is specified as a module argument.

When bypassed the module is still active and continues to perform the conversion.

Notes on fract conversions

Conversion between int and fract32 (or fract16) types performs a reinterpret cast — the raw bit pattern is preserved, not the numeric value. For example, converting 0.5 (fract32) to int yields 2^30 (1,073,741,824), not 0 or 1.

To obtain a true numeric conversion from fract32 to an integer limited to {−1, 0, 1}, use one of the following:

  • Double TypeConvert (simplest): chain fract32 → float then float → int. The float-to-int step rounds to nearest, so any fract32 value in [−1.0, 1.0) maps to exactly −1, 0, or 1.
  • Logic compare: subtract a LogicCompareConst (< −0.5) result from a LogicCompareConst (> 0.5) result using SubtractInt32.

Fract32-to-float and float-to-fract32 conversions are always true numeric casts and are not affected by this behavior.

Module Pack

Standard

ClassID

classID = 102

Type Definition

typedef struct _ModuleTypeConversion
{
ModuleInstanceDescriptor instance;            // Common Audio Weaver module instance structure
INT32 inputType;                              // Specifies the dataType of the input
INT32 outputType;                             // Specifies the dataType of the output
} ModuleTypeConversionClass;

Variables

Properties

Name Type Usage isHidden Default Value Range Units
inputType int parameter 1 0 0:3
outputType int parameter 1 0 0:3

Pins

Input Pins

Name in
Description Input signal
Data type {float, int, fract32, fract16}
Channel range Unrestricted
Block size range Unrestricted
Sample rate range Unrestricted
Complex support Real and Complex

Output Pins

Name out
Description Output signal
Data Type float

Matlab Usage

File Name: type_conversion_module.m 
 M = type_conversion_module(NAME, OUTPUTTYPE) 
 This modules converts between numeric data types.  For example, from 
 fract32 to floating-point.  Arguments: 
    NAME - name of the module. 
    OUTPUTTYPE - this specifies the type of the output data.  Allowable 
        values are:  0=float, 1=fract32, 2=int32, 3=fract16 

Copyright (c) 2026 DSP Concepts, Inc.