#define MAX_INT_FLOAT 32768.0
将每两个字节转换成一个float数据
Byte *bytes = (Byte *)[inputData bytes];
for(int i=0;i<[inputData length];i = i + 2){
Byte tByte[2];
tByte[0] = bytes[i];
tByte[1] = bytes[i + 1];
short number;
memcpy(&number, &tByte, sizeof(tByte));
[self.cacheData addObject:[NSNumber numberWithFloat:number/(double)MAX_INT_FLOAT]];
}
网友评论