10-29-2010 10:42 AM
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));
}
10-29-2010 11:44 AM
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.
10-29-2010 12:24 PM
Thank you very much!