union { /* 定义一个联合 */
int i;
struct { /* 在联合中定义一个结构 */
char first;
char second;
}half;
}number;
number.i = 0x4241; /* 联合成员赋值 */
cout << number.half.first << number.half.second << endl;
number.half.first = 'a'; /* 联合中结构成员赋值 */
number.half.second = 'b';
cout << number.i << endl; union { /* 定义一个联合 */
int i;
struct { /* 在联合中定义一个结构 */
char first;
char second;
}half;
}number;
number.i = 0x4241; /* 联合成员赋值 */
cout << number.half.first << number.half.second << endl;
number.half.first = 'a'; /* 联合中结构成员赋值 */
number.half.second = 'b';
cout << number.i << endl;
a的ascii码是0x61
b的ascii码是0x62
那么联合体里int对应的16进制就是0x00006261,转成10进制不是正好25185吗
这个过程哪里不理解可以问
对于64位的浮点数,最高的1位是符号位S,接着的11位是指数E,剩下的52位为有效数字M。