OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libquadmath/] [strtod/] [mpn2flt128.c] - Blame information for rev 760

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 740 jeremybenn
/* Copyright (C) 1995,1996,1997,1998,1999,2002,2003
2
        Free Software Foundation, Inc.
3
   This file is part of the GNU C Library.
4
 
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.
9
 
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.
14
 
15
   You should have received a copy of the GNU Lesser General Public
16
   License along with the GNU C Library; if not, write to the Free
17
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18
   02111-1307 USA.  */
19
 
20
#include <config.h>
21
#include <float.h>
22
#include <math.h>
23
#include "../printf/gmp-impl.h"
24
 
25
/* Convert a multi-precision integer of the needed number of bits (113 for
26
   long double) and an integral power of two to a `long double' in IEEE854
27
   quad-precision format.  */
28
 
29
__float128
30
mpn_construct_float128 (mp_srcptr frac_ptr, int expt, int sign)
31
{
32
  ieee854_float128 u;
33
 
34
  u.ieee.negative = sign;
35
  u.ieee.exponent = expt + IEEE854_FLOAT128_BIAS;
36
#if BITS_PER_MP_LIMB == 32
37
  u.ieee.mant_low = (((uint64_t) frac_ptr[1]) << 32)
38
                    | (frac_ptr[0] & 0xffffffff);
39
  u.ieee.mant_high = (((uint64_t) frac_ptr[3]
40
                       & (((mp_limb_t) 1 << (FLT128_MANT_DIG - 96)) - 1))
41
                      << 32) | (frac_ptr[2] & 0xffffffff);
42
#elif BITS_PER_MP_LIMB == 64
43
  u.ieee.mant_low = frac_ptr[0];
44
  u.ieee.mant_high = frac_ptr[1]
45
                     & (((mp_limb_t) 1 << (FLT128_MANT_DIG - 64)) - 1);
46
#else
47
  #error "mp_limb size " BITS_PER_MP_LIMB "not accounted for"
48
#endif
49
 
50
  return u.value;
51
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.