cancel
Showing results for
Show  only  | Search instead for
Did you mean:
Explorer
301 Views
Registered: ‎03-29-2017

## HLS : How to convert integer values into floating point ?

Hi!

Question looks simple but i am not familiar in working in floating point format. So please guide me.

I wrote a functional block without using compression which contain In-phase (I) Sample = 16 bits & Quadrature (Q) samples =16 bits // Totally IQ = 32 bit value.

Now I am in need to move into compression technique. I need to convert In-phase (I) and Quadrature (Q) samples into floating point format.

1. Subsequently, the samples are presented as a compressed bit sign and a mantissa (e.g., 9-bit) and a shared exponent.

2. The I and Q samples are subsequently compressed to a bit signed mantissa and unsigned exponent.

I have added "#include"math.h" in my function but i dont know how it can be proceeded (done) ? Please suggest me.

3 Replies
Teacher
299 Views
Registered: ‎05-11-2015

Have you tried a cast?

``````float x;

x = (float)int_var;``````

Actually, just assigning an int to a float should perform the operation, maybe with a warning.

Explorer
283 Views
Registered: ‎03-29-2017

Consider int_var is 2 dimensional array

int_var={0x0001 0x1111                    // I = 16 bits & Q = 16 bits
0x0010 0x1011
0x0011 0x1010
0x0100 0x1001
0x0101 0x1000
0x0110 0x0111
0x0111 0x0110
0x1000 0x0101
0x1001 0x0100
0x1010 0x0011
0x1011 0x0010
0x1111 0x0001 }

x=(float) int_var  ///////Will it work ??

Teacher
264 Views
Registered: ‎05-11-2015

You cannot copy arrays straight away, but a for loop will definitely do the job.