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 typedef union
00009 {
00010   long double value;
00011   struct
00012   {
00013     u_int32_t lsw;
00014     u_int32_t msw;
00015     int sign_exponent:16;
00016     unsigned int empty1:16;
00017     unsigned int empty0:32;
00018   } parts;
00019 } ieee_long_double_shape_type;
00020 
00021 /* Get three 32 bit ints from a double.  */
00022 
00023 #define GET_LDOUBLE_WORDS(exp,ix0,ix1,d)                \
00024 do {                                                    \
00025   ieee_long_double_shape_type ew_u;                            \
00026   ew_u.value = (d);                                     \
00027   (exp) = ew_u.parts.sign_exponent;                            \
00028   (ix0) = ew_u.parts.msw;                               \
00029   (ix1) = ew_u.parts.lsw;                               \
00030 } while (0)
00031 
00032 /* Set a double from two 32 bit ints.  */
00033 
00034 #define SET_LDOUBLE_WORDS(d,exp,ix0,ix1)                \
00035 do {                                                    \
00036   ieee_long_double_shape_type iw_u;                            \
00037   iw_u.parts.sign_exponent = (exp);                            \
00038   iw_u.parts.msw = (ix0);                               \
00039   iw_u.parts.lsw = (ix1);                               \
00040   (d) = iw_u.value;                                     \
00041 } while (0)
00042 
00043 /* Get the more significant 32 bits of a long double mantissa.  */
00044 
00045 #define GET_LDOUBLE_MSW(v,d)                                   \
00046 do {                                                    \
00047   ieee_long_double_shape_type sh_u;                            \
00048   sh_u.value = (d);                                     \
00049   (v) = sh_u.parts.msw;                                        \
00050 } while (0)
00051 
00052 /* Set the more significant 32 bits of a long double mantissa from an int.  */
00053 
00054 #define SET_LDOUBLE_MSW(d,v)                                   \
00055 do {                                                    \
00056   ieee_long_double_shape_type sh_u;                            \
00057   sh_u.value = (d);                                     \
00058   sh_u.parts.msw = (v);                                        \
00059   (d) = sh_u.value;                                     \
00060 } while (0)
00061 
00062 /* Get int from the exponent of a long double.  */
00063 
00064 #define GET_LDOUBLE_EXP(exp,d)                                 \
00065 do {                                                    \
00066   ieee_long_double_shape_type ge_u;                            \
00067   ge_u.value = (d);                                     \
00068   (exp) = ge_u.parts.sign_exponent;                            \
00069 } while (0)
00070 
00071 /* Set exponent of a long double from an int.  */
00072 
00073 #define SET_LDOUBLE_EXP(d,exp)                                 \
00074 do {                                                    \
00075   ieee_long_double_shape_type se_u;                            \
00076   se_u.value = (d);                                     \
00077   se_u.parts.sign_exponent = (exp);                            \
00078   (d) = se_u.value;                                     \
00079 } while (0)