其实很简单,但是自己计算机基础不好,惭愧!
1.浮点数转十六进制
float a= -104.05;
long b = *(long*)&a;
NSString *str = [NSString stringWithFormat:@"%lx",b];
2.十六进制转浮点数
NSString*hexStr =@"42E41999";
NSData*dddtt = [self dataWithHexstring:finalStr];
intresult = -1;
Byte*bytes = (Byte*)[dddtt bytes];
result =CFSwapInt32BigToHost(*(int*)bytes);
floatchc = *(float*)&result;
废了九牛二虎之力,找到的答案,如果能帮到你,记得打赏支持一下.