の指数IがHow to get the sign, mantissa and exponent of a floating point numberサインオン、仮数、およびダブル
#include <stdio.h>
typedef union {
float f;
struct {
unsigned int mantisa : 23;
unsigned int exponent : 8;
unsigned int sign : 1;
} parts;
} double_cast;
int main() {
double_cast d1;
d1.f = 0.15625;
printf("sign = %x\n",d1.parts.sign);
printf("exponent = %x\n",d1.parts.exponent);
printf("mantisa = %x\n",d1.parts.mantisa);
return 0;
}
から次のコードを見つけしかし、どのように、私は11であること、仮数値が52であることと、二重指数として、それをキャストしないと、1であることに署名?
ありがとうございます、長年の宣言は何ですか? 8文字の値はどうですか? – OregonState2016
'long'は8バイトか4バイトか何でもかまいません。そのため、' 'はそこにあります:定義されたサイズの統一型を提供するためです。 –
C標準はビットフィールドの配置方法を制限しないので、それはあまり移植性がありません。 – 2501