LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Converting C code to Labview

Can someone please help me convert this function to Laview code.  Thank you very much!

 

const float fmax19 = (float)0x07FFFF;

float IQ19ToFloat(int value)
{
   float frac = (float)(value & 0x0007FFFF);
   int rint = (value & 0xFFF80000) >> 19;
   // convert 2's compliment to float
   int s = rint & 0x1000;
   int m = rint & 0x7fff;
   int sm = (s - 1)^(-1);
   int x = m | sm;
   float fint = (float)(x);
   return (fint + (frac / fmax19));
}


0 Kudos
Message 1 of 3
(3,044 Views)

As far as I can tell, this code converts a integer representation of a fixed-point value (19 bits unsigned, no integer bits) to an equivalent floating-point value.  If you have the fixed-point palette (might be available only with the FPGA toolkit), use "Integer to Fixed-Point Cast."  If you don't have the fixed-point palette, just convert the integer to a floating point, then "shift" it by 19 bits using "Scale by Power of 2."  Of course, if you really want to do it the hard way, you can do a direct conversion of the C algorithm.

1Q19ToFloat.png

Message 2 of 3
(3,016 Views)

Thank you very much!

0 Kudos
Message 3 of 3
(2,997 Views)