1 /* Manipulation of the bit representation of 'long double' quantities.
2 Copyright (C) 2000-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
20 #define _MATH_LDBL_H_ 1
25 /* A union which permits us to convert between a long double and
28 #if __FLOAT_WORD_ORDER == __BIG_ENDIAN
35 unsigned int empty0
:32;
37 unsigned int empty1
:16;
41 } ieee_long_double_shape_type
;
45 #if __FLOAT_WORD_ORDER == __LITTLE_ENDIAN
55 unsigned int empty1
:16;
56 unsigned int empty0
:32;
58 } ieee_long_double_shape_type
;
62 /* Get three 32 bit ints from a double. */
64 #define GET_LDOUBLE_WORDS(exp,ix0,ix1,d) \
66 ieee_long_double_shape_type ew_u; \
68 (exp) = ew_u.parts.sign_exponent; \
69 (ix0) = ew_u.parts.msw; \
70 (ix1) = ew_u.parts.lsw; \
73 /* Set a double from two 32 bit ints. */
75 #define SET_LDOUBLE_WORDS(d,exp,ix0,ix1) \
77 ieee_long_double_shape_type iw_u; \
78 iw_u.parts.sign_exponent = (exp); \
79 iw_u.parts.msw = (ix0); \
80 iw_u.parts.lsw = (ix1); \
84 /* Get the more significant 32 bits of a long double mantissa. */
86 #define GET_LDOUBLE_MSW(v,d) \
88 ieee_long_double_shape_type sh_u; \
90 (v) = sh_u.parts.msw; \
93 /* Set the more significant 32 bits of a long double mantissa from an int. */
95 #define SET_LDOUBLE_MSW(d,v) \
97 ieee_long_double_shape_type sh_u; \
99 sh_u.parts.msw = (v); \
103 /* Get int from the exponent of a long double. */
105 #define GET_LDOUBLE_EXP(exp,d) \
107 ieee_long_double_shape_type ge_u; \
109 (exp) = ge_u.parts.sign_exponent; \
112 /* Set exponent of a long double from an int. */
114 #define SET_LDOUBLE_EXP(d,exp) \
116 ieee_long_double_shape_type se_u; \
118 se_u.parts.sign_exponent = (exp); \
122 #endif /* math_ldbl.h */