Mercurial > hg > CbC > CbC_gcc
comparison gcc/realmpfr.c @ 146:351920fa3827
merge
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 01 Mar 2020 16:13:28 +0900 |
parents | 1830386684a0 |
children |
comparison
equal
deleted
inserted
replaced
144:8f4e72ab4e11 | 146:351920fa3827 |
---|---|
1 /* Conversion routines from GCC internal float representation to MPFR. | 1 /* Conversion routines from GCC internal float representation to MPFR. |
2 Copyright (C) 2010-2018 Free Software Foundation, Inc. | 2 Copyright (C) 2010-2020 Free Software Foundation, Inc. |
3 | 3 |
4 This file is part of GCC. | 4 This file is part of GCC. |
5 | 5 |
6 GCC is free software; you can redistribute it and/or modify it under | 6 GCC is free software; you can redistribute it and/or modify it under |
7 the terms of the GNU General Public License as published by the Free | 7 the terms of the GNU General Public License as published by the Free |
26 | 26 |
27 /* Convert from REAL_VALUE_TYPE to MPFR. The caller is responsible | 27 /* Convert from REAL_VALUE_TYPE to MPFR. The caller is responsible |
28 for initializing and clearing the MPFR parameter. */ | 28 for initializing and clearing the MPFR parameter. */ |
29 | 29 |
30 void | 30 void |
31 mpfr_from_real (mpfr_ptr m, const REAL_VALUE_TYPE *r, mp_rnd_t rndmode) | 31 mpfr_from_real (mpfr_ptr m, const REAL_VALUE_TYPE *r, mpfr_rnd_t rndmode) |
32 { | 32 { |
33 /* We use a string as an intermediate type. */ | 33 /* We use a string as an intermediate type. */ |
34 char buf[128]; | 34 char buf[128]; |
35 int ret; | 35 int ret; |
36 | 36 |
57 /* Convert from MPFR to REAL_VALUE_TYPE, for a given format FORMAT and | 57 /* Convert from MPFR to REAL_VALUE_TYPE, for a given format FORMAT and |
58 rounding mode RNDMODE. FORMAT is only relevant if M is a NaN. */ | 58 rounding mode RNDMODE. FORMAT is only relevant if M is a NaN. */ |
59 | 59 |
60 void | 60 void |
61 real_from_mpfr (REAL_VALUE_TYPE *r, mpfr_srcptr m, const real_format *format, | 61 real_from_mpfr (REAL_VALUE_TYPE *r, mpfr_srcptr m, const real_format *format, |
62 mp_rnd_t rndmode) | 62 mpfr_rnd_t rndmode) |
63 { | 63 { |
64 /* We use a string as an intermediate type. */ | 64 /* We use a string as an intermediate type. */ |
65 char buf[128], *rstr; | 65 char buf[128], *rstr; |
66 mp_exp_t exp; | 66 mpfr_exp_t exp; |
67 | 67 |
68 /* Take care of Infinity and NaN. */ | 68 /* Take care of Infinity and NaN. */ |
69 if (mpfr_inf_p (m)) | 69 if (mpfr_inf_p (m)) |
70 { | 70 { |
71 real_inf (r); | 71 real_inf (r); |
103 | 103 |
104 /* Convert from MPFR to REAL_VALUE_TYPE, for a given type TYPE and rounding | 104 /* Convert from MPFR to REAL_VALUE_TYPE, for a given type TYPE and rounding |
105 mode RNDMODE. TYPE is only relevant if M is a NaN. */ | 105 mode RNDMODE. TYPE is only relevant if M is a NaN. */ |
106 | 106 |
107 void | 107 void |
108 real_from_mpfr (REAL_VALUE_TYPE *r, mpfr_srcptr m, tree type, mp_rnd_t rndmode) | 108 real_from_mpfr (REAL_VALUE_TYPE *r, mpfr_srcptr m, tree type, |
109 mpfr_rnd_t rndmode) | |
109 { | 110 { |
110 real_from_mpfr (r, m, type ? REAL_MODE_FORMAT (TYPE_MODE (type)) : NULL, | 111 real_from_mpfr (r, m, type ? REAL_MODE_FORMAT (TYPE_MODE (type)) : NULL, |
111 rndmode); | 112 rndmode); |
112 } | 113 } |
113 | 114 |