2010-08-04 15:03:19 -04:00
|
|
|
union ieee754_float {
|
2008-06-30 21:53:51 -04:00
|
|
|
float f;
|
|
|
|
|
2010-08-04 15:03:19 -04:00
|
|
|
struct {
|
|
|
|
#if BYTE_ORDER == BIG_ENDIAN
|
2019-08-09 07:02:02 -04:00
|
|
|
unsigned int negative : 1;
|
|
|
|
unsigned int exponent : 8;
|
|
|
|
unsigned int mantissa : 23;
|
2010-08-04 15:03:19 -04:00
|
|
|
#endif
|
|
|
|
#if BYTE_ORDER == LITTLE_ENDIAN
|
2019-08-09 07:02:02 -04:00
|
|
|
unsigned int mantissa : 23;
|
|
|
|
unsigned int exponent : 8;
|
|
|
|
unsigned int negative : 1;
|
2010-08-04 15:03:19 -04:00
|
|
|
#endif
|
|
|
|
} ieee;
|
|
|
|
};
|
2008-06-30 21:53:51 -04:00
|
|
|
|
2010-08-04 15:03:19 -04:00
|
|
|
#define IEEE754_FLOAT_BIAS 0x7f
|
2008-06-30 21:53:51 -04:00
|
|
|
|
2010-08-04 15:03:19 -04:00
|
|
|
union ieee754_double {
|
2008-06-30 21:53:51 -04:00
|
|
|
double d;
|
|
|
|
|
2010-08-04 15:03:19 -04:00
|
|
|
struct {
|
|
|
|
#if BYTE_ORDER == BIG_ENDIAN
|
2019-08-09 07:02:02 -04:00
|
|
|
unsigned int negative : 1;
|
|
|
|
unsigned int exponent : 11;
|
|
|
|
unsigned int mantissa0 : 20;
|
|
|
|
unsigned int mantissa1 : 32;
|
2010-08-04 15:03:19 -04:00
|
|
|
#endif
|
|
|
|
#if BYTE_ORDER == LITTLE_ENDIAN
|
2019-08-09 07:02:02 -04:00
|
|
|
unsigned int mantissa1 : 32;
|
|
|
|
unsigned int mantissa0 : 20;
|
|
|
|
unsigned int exponent : 11;
|
|
|
|
unsigned int negative : 1;
|
2008-06-30 21:53:51 -04:00
|
|
|
#endif
|
2010-08-04 15:03:19 -04:00
|
|
|
} ieee;
|
|
|
|
};
|
2008-06-30 21:53:51 -04:00
|
|
|
|
2010-08-04 15:03:19 -04:00
|
|
|
#define IEEE754_DOUBLE_BIAS 0x3ff
|
2008-06-30 21:53:51 -04:00
|
|
|
|
2010-08-04 15:03:19 -04:00
|
|
|
union ieee854_long_double {
|
2008-06-30 21:53:51 -04:00
|
|
|
long double d;
|
|
|
|
|
2010-08-04 15:03:19 -04:00
|
|
|
struct {
|
|
|
|
#if BYTE_ORDER == BIG_ENDIAN
|
2019-08-09 07:02:02 -04:00
|
|
|
unsigned int negative : 1;
|
|
|
|
unsigned int exponent : 15;
|
|
|
|
unsigned int empty : 16;
|
|
|
|
unsigned int mantissa0 : 32;
|
|
|
|
unsigned int mantissa1 : 32;
|
2008-06-30 21:53:51 -04:00
|
|
|
#endif
|
2010-08-04 15:03:19 -04:00
|
|
|
#if BYTE_ORDER == LITTLE_ENDIAN
|
2019-08-09 07:02:02 -04:00
|
|
|
unsigned int mantissa1 : 32;
|
|
|
|
unsigned int mantissa0 : 32;
|
|
|
|
unsigned int exponent : 15;
|
|
|
|
unsigned int negative : 1;
|
|
|
|
unsigned int empty : 16;
|
2008-06-30 21:53:51 -04:00
|
|
|
#endif
|
2010-08-04 15:03:19 -04:00
|
|
|
} ieee;
|
|
|
|
};
|
2008-06-30 21:53:51 -04:00
|
|
|
|
|
|
|
#define IEEE854_LONG_DOUBLE_BIAS 0x3fff
|