J
jawilson2
Hello,
I have some data that stores two 16-bit integers in a 32-bit float, and
I would like to extract the data. I want to do something like
//-----------------------------------------------------------------
float *data;
short *buff;
int dataLen; //number of points in data
//other code...
for (i = 0; i < dataLen; i++)
{
buff[2*i] = (data & 0x0F); // place the lower 16 bits in the
first sample
buff[2*i + 1] = (data & 0xF0) >> 16; //place the upper 16 bits
(and bit shifted)in the second sample
}
//------------------------------------------------------------------
Does this make sense? I'm thinking it will involve casting the data
variable as an int/short somehow, using something like:
buff[2*i] = ( *(int*)&data ...); //found this on another forum, does
this work?
Any ideas?
Thanks!
I have some data that stores two 16-bit integers in a 32-bit float, and
I would like to extract the data. I want to do something like
//-----------------------------------------------------------------
float *data;
short *buff;
int dataLen; //number of points in data
//other code...
for (i = 0; i < dataLen; i++)
{
buff[2*i] = (data & 0x0F); // place the lower 16 bits in the
first sample
buff[2*i + 1] = (data & 0xF0) >> 16; //place the upper 16 bits
(and bit shifted)in the second sample
}
//------------------------------------------------------------------
Does this make sense? I'm thinking it will involve casting the data
variable as an int/short somehow, using something like:
buff[2*i] = ( *(int*)&data ...); //found this on another forum, does
this work?
Any ideas?
Thanks!