diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2002-03-11 13:16:54 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2002-03-11 13:16:54 +0000 |
commit | 5c4878caf36a75b23817d7ef7327293e286cafeb (patch) | |
tree | cd8b26bb96a13fc7271eab521889033d296c6991 | |
parent | e3956a44b0baf2c582345103957f97f890d759cf (diff) | |
download | mpfr-5c4878caf36a75b23817d7ef7327293e286cafeb.tar.gz |
New mpfr_get_d, mpfr_get_d2, mpfr_get_d3.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@1726 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r-- | TODO | 2 | ||||
-rw-r--r-- | get_d.c | 10 | ||||
-rw-r--r-- | get_str.c | 2 | ||||
-rw-r--r-- | mpfr-impl.h | 2 | ||||
-rw-r--r-- | mpfr.h | 3 | ||||
-rw-r--r-- | mpfr.texi | 7 | ||||
-rw-r--r-- | tests/tget_d.c | 11 |
7 files changed, 30 insertions, 7 deletions
@@ -65,3 +65,5 @@ i.e.0.10101011100001010011001101100101110011101110010001011000000000000000000000 - rename mpfr_isinteger to mpfr_integer_p. (Kevin Ryde, 05 Mar 2002) + +- rewrite mpfr_get_d3 (new specification) and the corresponding tests. @@ -90,7 +90,7 @@ __mpfr_scale2 (double d, int exp) } double -mpfr_get_d2 (mpfr_srcptr src, mp_exp_t e) +mpfr_get_d3 (mpfr_srcptr src, mp_exp_t e, mp_rnd_t rnd_mode) { double d; mpfr_t tmp; @@ -157,7 +157,13 @@ mpfr_get_d2 (mpfr_srcptr src, mp_exp_t e) } double +mpfr_get_d2 (mpfr_srcptr src, mp_rnd_t rnd_mode) +{ + return mpfr_get_d3 (src, MPFR_EXP(src), rnd_mode); +} + +double mpfr_get_d (mpfr_srcptr src) { - return mpfr_get_d2 (src, MPFR_EXP(src)); + return mpfr_get_d3 (src, MPFR_EXP(src), __gmp_default_rounding_mode); } @@ -138,7 +138,7 @@ mpfr_get_str (char *str, mp_exp_t *expptr, int base, size_t n, { double d; - d = mpfr_get_d2(op, 0); + d = mpfr_get_d3(op, 0, GMP_RNDN); d = ((double) e + (double) _mpfr_floor_log2 (ABS(d))) * __mp_bases[base].chars_per_bit_exactly; MPFR_ASSERTN(d >= MP_EXP_T_MIN); diff --git a/mpfr-impl.h b/mpfr-impl.h index f94e097a0..ce0e82ba6 100644 --- a/mpfr-impl.h +++ b/mpfr-impl.h @@ -180,7 +180,7 @@ int mpfr_round_raw_generic _PROTO ((mp_limb_t *, mp_limb_t *, mp_prec_t, int, mp_prec_t, mp_rnd_t, int *, int)); int mpfr_can_round_raw _PROTO ((mp_limb_t *, mp_size_t, int, mp_exp_t, mp_rnd_t, mp_rnd_t, mp_prec_t)); -double mpfr_get_d2 _PROTO ((mpfr_srcptr, mp_exp_t)); +double mpfr_get_d3 _PROTO ((mpfr_srcptr, mp_exp_t, mp_rnd_t)); mp_size_t mpn_sqrtrem_new _PROTO ((mp_limb_t *, mp_limb_t *, mp_limb_t *, mp_size_t)); int mpfr_cmp_abs _PROTO ((mpfr_srcptr, mpfr_srcptr)); int mpfr_cmp2 _PROTO ((mpfr_srcptr, mpfr_srcptr, mp_prec_t *)); @@ -145,7 +145,8 @@ int mpfr_set_d _PROTO ((mpfr_ptr, double, mp_rnd_t)); int mpfr_set_z _PROTO ((mpfr_ptr, mpz_srcptr, mp_rnd_t)); mp_exp_t mpfr_get_z_exp _PROTO ((mpz_ptr, mpfr_srcptr)); int mpfr_set_q _PROTO ((mpfr_ptr, mpq_srcptr, mp_rnd_t)); -double mpfr_get_d _PROTO ((mpfr_srcptr)); +double mpfr_get_d _PROTO ((mpfr_srcptr)); +double mpfr_get_d2 _PROTO ((mpfr_srcptr, mp_rnd_t)); int mpfr_set_f _PROTO ((mpfr_ptr, mpf_srcptr, mp_rnd_t)); int mpfr_set_si _PROTO ((mpfr_ptr, long, mp_rnd_t)); int mpfr_set_ui _PROTO ((mpfr_ptr, unsigned long, mp_rnd_t)); @@ -815,8 +815,13 @@ See @code{mpfr_set_str}. @section Conversion Functions @cindex Conversion functions +@deftypefun double mpfr_get_d2 (mpfr_t @var{op}, mp_rnd_t @var{rnd}) +Convert @var{op} to a double, using the rounding mode @var{rnd}. +@end deftypefun + @deftypefun double mpfr_get_d (mpfr_t @var{op}) -Convert @var{op} to a double, using the current @emph{machine} rounding mode. +Convert @var{op} to a double, using the default MPFR rounding mode +(see function @code{mpfr_set_default_rounding_mode}). @end deftypefun @deftypefun mp_exp_t mpfr_get_z_exp (mpz_t @var{z}, mpfr_t @var{op}) diff --git a/tests/tget_d.c b/tests/tget_d.c index 5626ffa2c..745fdfa8f 100644 --- a/tests/tget_d.c +++ b/tests/tget_d.c @@ -26,12 +26,14 @@ MA 02111-1307, USA. */ #include "mpfr.h" #include "mpfr-impl.h" -#define TEST #include "rnd_mode.c" int main (void) { + +#ifdef TEST + mpfr_t half, x, y; mp_rnd_t rnd_mode; @@ -105,5 +107,12 @@ main (void) mpfr_clear(half); mpfr_clear(x); mpfr_clear(y); + +#else + + fprintf(stderr, "Disabled\n"); + +#endif + return 0; } |