ΣSigmaStudio Ask AI Русский Log in

fract16  conversion

Processors & DSP ama Jun 17, 2011 00:00 1 replies Original on forum ↗
Subscribe
ama Question
Jun 17, 2011 00:00

Hello,

I am dealing with data in "int", "short" and "double" and I want to filter it by IIR, so.

How can I convert from fract16 to double, short and int and vice versa?

I have found a relation to convert from int to fract16, by dividing the int values by 32768 to get a fraction between -1 and 1-2^(-15). But if there is a built in function like float_to_frct()

thank you very much and best regards,

ama

ADIApproved Reply
Jun 20, 2011 00:00

ama,

There is a set of conversion fundctions. You can see the relevant functions at the following locations in the "C/C++ Compiler and Library Manual for Blackfin Processors" manual in:

Ch.1 Compiler > C/C++ Compiler Language Extensions > Compiler Built-In Functions > Converting Between Fractional and Floating-Point Values

Ch.1 Compiler > Using Native Fixed-Point Types > Porting Code Written Using fract16 and fract32

Specifically, the two conversion functions that may help you are:

fract32 float_to_fr32(float); // Converts a float to fract32
fract16 float_to_fr16(float); // Converts a float to fract16