取double数据位上8位的数据:
思路:将数据右移8位,每移动8位,将需要的数据位移动到最低位,与0x00FF相与得到的结果为该8位上的数据。
代码:
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
double data = 47289.0;
unsigned int i = data;
cout << i << endl;
cout << (i & 0X00FF) << endl;
unsigned int j=i >> 8;
cout << (j & 0X00FF) << endl;
unsigned int m = j >> 8;
cout << (m & 0X00FF) << endl;
return 0;
}