唉,被符号转换坑了,白浪费了2天,上来给自己立个碑
本帖最后由 dahuatttt 于 2013-09-14 01:03:58 编辑
unsigned char t[2];
t[0] = 0x50;
t[1] = 0xF9;
float a = ((t[1]<<8)| (0x00ff&(int)t[0]))/32768.f;
cout << hex<< *(int*)&a << endl;
// 输出3FF95000
char t[2];
t[0] = 0x50;
t[1] = 0xF9;
float a = ((t[1]<<8)| (0x00ff&(int)t[1]))/32768.f;
cout << hex<< *(int*)&a << endl;
// 输出BD560000
unsigned char t[2];
t[0] = 0x50;
004113DE mov byte ptr [t],50h
t[1] = 0xF9;
004113E2 mov byte ptr [ebp-7],0F9h
float a = ((t[1]<<8)
[解决办法]
(0x00ff&(int)t[0]))/32768.f;
004113E6 movzx eax,byte ptr [ebp-7]
004113EA shl eax,8
004113ED movzx ecx,byte ptr [t]
char t1[2];
t1[0] = 0x50;
00411454 mov byte ptr [t1],50h
t1[1] = 0xF9;
00411458 mov byte ptr [ebp-1Fh],0F9h
float a1 = ((t1[1]<<8)
[解决办法]
(0x00ff&(int)t1[1]))/32768.f;
0041145C movsx eax,byte ptr [ebp-1Fh]
00411460 shl eax,8
00411463 movsx ecx,byte ptr [ebp-1Fh]