]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libquadmath/strtod/mpn2flt128.c
1 /* Copyright (C) 1995-2013 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 #include "../printf/gmp-impl.h"
24 /* Convert a multi-precision integer of the needed number of bits (113 for
25 long double) and an integral power of two to a `long double' in IEEE854
26 quad-precision format. */
29 mpn_construct_float128 (mp_srcptr frac_ptr
, int expt
, int sign
)
33 u
.ieee
.negative
= sign
;
34 u
.ieee
.exponent
= expt
+ IEEE854_FLOAT128_BIAS
;
35 #if BITS_PER_MP_LIMB == 32
36 u
.ieee
.mant_low
= (((uint64_t) frac_ptr
[1]) << 32)
37 | (frac_ptr
[0] & 0xffffffff);
38 u
.ieee
.mant_high
= (((uint64_t) frac_ptr
[3]
39 & (((mp_limb_t
) 1 << (FLT128_MANT_DIG
- 96)) - 1))
40 << 32) | (frac_ptr
[2] & 0xffffffff);
41 #elif BITS_PER_MP_LIMB == 64
42 u
.ieee
.mant_low
= frac_ptr
[0];
43 u
.ieee
.mant_high
= frac_ptr
[1]
44 & (((mp_limb_t
) 1 << (FLT128_MANT_DIG
- 64)) - 1);
46 #error "mp_limb size " BITS_PER_MP_LIMB "not accounted for"