Back to index

glibc  2.9
math_ldbl.h
Go to the documentation of this file.
00001 #ifndef _MATH_PRIVATE_H_
00002 #error "Never use <math_ldbl.h> directly; include <math_private.h> instead."
00003 #endif
00004 
00005 /* A union which permits us to convert between a long double and
00006    three 32 bit ints.  */
00007 
00008 #if __FLOAT_WORD_ORDER == BIG_ENDIAN
00009 
00010 typedef union
00011 {
00012   long double value;
00013   struct
00014   {
00015     int sign_exponent:16;
00016     unsigned int empty:16;
00017     u_int32_t msw;
00018     u_int32_t lsw;
00019   } parts;
00020 } ieee_long_double_shape_type;
00021 
00022 #endif
00023 
00024 #if __FLOAT_WORD_ORDER == LITTLE_ENDIAN
00025 
00026 typedef union
00027 {
00028   long double value;
00029   struct
00030   {
00031     u_int32_t lsw;
00032     u_int32_t msw;
00033     int sign_exponent:16;
00034     unsigned int empty:16;
00035   } parts;
00036 } ieee_long_double_shape_type;
00037 
00038 #endif
00039 
00040 /* Get three 32 bit ints from a double.  */
00041 
00042 #define GET_LDOUBLE_WORDS(exp,ix0,ix1,d)                \
00043 do {                                                    \
00044   ieee_long_double_shape_type ew_u;                            \
00045   ew_u.value = (d);                                     \
00046   (exp) = ew_u.parts.sign_exponent;                            \
00047   (ix0) = ew_u.parts.msw;                               \
00048   (ix1) = ew_u.parts.lsw;                               \
00049 } while (0)
00050 
00051 /* Set a double from two 32 bit ints.  */
00052 
00053 #define SET_LDOUBLE_WORDS(d,exp,ix0,ix1)                \
00054 do {                                                    \
00055   ieee_long_double_shape_type iw_u;                            \
00056   iw_u.parts.sign_exponent = (exp);                            \
00057   iw_u.parts.msw = (ix0);                               \
00058   iw_u.parts.lsw = (ix1);                               \
00059   (d) = iw_u.value;                                     \
00060 } while (0)
00061 
00062 /* Get the more significant 32 bits of a long double mantissa.  */
00063 
00064 #define GET_LDOUBLE_MSW(v,d)                                   \
00065 do {                                                    \
00066   ieee_long_double_shape_type sh_u;                            \
00067   sh_u.value = (d);                                     \
00068   (v) = sh_u.parts.msw;                                        \
00069 } while (0)
00070 
00071 /* Set the more significant 32 bits of a long double mantissa from an int.  */
00072 
00073 #define SET_LDOUBLE_MSW(d,v)                                   \
00074 do {                                                    \
00075   ieee_long_double_shape_type sh_u;                            \
00076   sh_u.value = (d);                                     \
00077   sh_u.parts.msw = (v);                                        \
00078   (d) = sh_u.value;                                     \
00079 } while (0)
00080 
00081 /* Get int from the exponent of a long double.  */
00082 
00083 #define GET_LDOUBLE_EXP(exp,d)                                 \
00084 do {                                                    \
00085   ieee_long_double_shape_type ge_u;                            \
00086   ge_u.value = (d);                                     \
00087   (exp) = ge_u.parts.sign_exponent;                            \
00088 } while (0)
00089 
00090 /* Set exponent of a long double from an int.  */
00091 
00092 #define SET_LDOUBLE_EXP(d,exp)                                 \
00093 do {                                                    \
00094   ieee_long_double_shape_type se_u;                            \
00095   se_u.value = (d);                                     \
00096   se_u.parts.sign_exponent = (exp);                            \
00097   (d) = se_u.value;                                     \
00098 } while (0)