其實(shí)很簡(jiǎn)單,但是自己計(jì)算機(jī)基礎(chǔ)不好,慚愧!
1.浮點(diǎn)數(shù)轉(zhuǎn)十六進(jìn)制
? float? a= -104.05;
? ?long? b = *(long*)&a;
? ?NSString *str = [NSString stringWithFormat:@"%lx",b];
2.十六進(jìn)制轉(zhuǎn)浮點(diǎn)數(shù)
? NSString*hexStr =@"42E41999";
? ?NSData*dddtt = [self dataWithHexstring:finalStr];
? ? intresult = -1;
? ? Byte*bytes = (Byte*)[dddtt bytes];
? ? result =CFSwapInt32BigToHost(*(int*)bytes);
? ? floatchc = *(float*)&result;
廢了九牛二虎之力,找到的答案,如果能幫到你,記得打賞支持一下.