summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author(no author) <(no author)@280ebfd0-de03-0410-8827-d642c229c3f4>2005-02-23 15:31:34 +0000
committer(no author) <(no author)@280ebfd0-de03-0410-8827-d642c229c3f4>2005-02-23 15:31:34 +0000
commit3ba60c4696b29ec5e6fdf1eb857e62a08db10bf6 (patch)
tree7015d2b8400e39199a46502bd34726fc83cc9ba5
parent72f6fe2312386189718003ff74b1be84c869d675 (diff)
downloadmpfr-3ba60c4696b29ec5e6fdf1eb857e62a08db10bf6.tar.gz
This commit was manufactured by cvs2svn to create tagmpfr-2-1-1-rel
'mpfr-2-1-1-rel'. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/tags/mpfr-2-1-1-rel@3351 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--AUTHORS7
-rw-r--r--BUGS11
-rw-r--r--ChangeLog441
-rw-r--r--INSTALL23
-rw-r--r--NEWS14
-rw-r--r--README6
-rw-r--r--README.dev34
-rw-r--r--VERSION2
-rw-r--r--acinclude.m416
-rw-r--r--configure.in36
-rw-r--r--exp.c4
-rw-r--r--get_str.c16
-rw-r--r--mpfr-impl.h17
-rw-r--r--mpfr-longlong.h93
-rw-r--r--mpfr-test.h10
-rw-r--r--mpfr.h6
-rw-r--r--mpfr.texi298
-rw-r--r--mpn_exp.c2
-rw-r--r--mul.c2
-rw-r--r--rint.c6
-rw-r--r--set.c6
-rw-r--r--set_d.c1
-rw-r--r--set_str.c17
-rw-r--r--strtofr.c367
-rw-r--r--sub1.c63
-rw-r--r--sum.c26
-rw-r--r--tan.c15
-rw-r--r--tests/Makefile.in920
-rw-r--r--tests/mpf_compat.h25
-rw-r--r--tests/tabs.c8
-rw-r--r--tests/tacos.c24
-rw-r--r--tests/tadd.c26
-rw-r--r--tests/tadd1sp.c73
-rw-r--r--tests/tadd_ui.c4
-rw-r--r--tests/tasin.c24
-rw-r--r--tests/tatan.c32
-rw-r--r--tests/tcan_round.c6
-rw-r--r--tests/tcbrt.c14
-rw-r--r--tests/tcmp.c21
-rw-r--r--tests/tcmpabs.c12
-rw-r--r--tests/tconst_euler.c14
-rw-r--r--tests/tconst_log2.c6
-rw-r--r--tests/tconst_pi.c6
-rw-r--r--tests/tcos.c8
-rw-r--r--tests/tcosh.c8
-rw-r--r--tests/tdiv.c16
-rw-r--r--tests/tdiv_ui.c10
-rw-r--r--tests/teq.c6
-rw-r--r--tests/tests.c52
-rw-r--r--tests/texceptions.c33
-rw-r--r--tests/texp.c24
-rw-r--r--tests/texp2.c16
-rw-r--r--tests/tfactorial.c24
-rw-r--r--tests/tfma.c4
-rw-r--r--tests/tfrac.c12
-rw-r--r--tests/tgamma.c8
-rw-r--r--tests/tgeneric.c4
-rw-r--r--tests/tget_d_2exp.c4
-rw-r--r--tests/tget_sj.c14
-rw-r--r--tests/tget_str.c345
-rw-r--r--tests/tgmpop.c28
-rw-r--r--tests/thypot.c4
-rw-r--r--tests/tinp_str.c3
-rw-r--r--tests/tlog.c12
-rw-r--r--tests/tmul.c12
-rw-r--r--tests/tmul_ui.c12
-rw-r--r--tests/tout_str.c11
-rw-r--r--tests/toutimpl.c4
-rw-r--r--tests/tpow.c16
-rw-r--r--tests/tpow3.c4
-rw-r--r--tests/trandom.c4
-rw-r--r--tests/trint.c53
-rw-r--r--tests/tround_prec.c4
-rw-r--r--tests/tset.c10
-rw-r--r--tests/tset_d.c17
-rw-r--r--tests/tset_exp.c4
-rw-r--r--tests/tset_f.c12
-rw-r--r--tests/tset_ld.c12
-rw-r--r--tests/tset_q.c20
-rw-r--r--tests/tset_si.c34
-rw-r--r--tests/tset_str.c367
-rw-r--r--tests/tset_z.c34
-rw-r--r--tests/tsqr.c16
-rw-r--r--tests/tsqrt.c4
-rw-r--r--tests/tstrtofr.c2
-rw-r--r--tests/tsub.c6
-rw-r--r--tests/tsub1sp.c675
-rw-r--r--tests/tsum.c12
-rw-r--r--tests/ttanh.c8
-rw-r--r--tests/tui_div.c10
-rw-r--r--tests/tui_pow.c4
-rw-r--r--tests/tui_sub.c8
-rw-r--r--tests/tzeta.c4
-rw-r--r--ui_sub.c12
-rw-r--r--version.c2
95 files changed, 2648 insertions, 2134 deletions
diff --git a/AUTHORS b/AUTHORS
index 4f0497a82..d23e692ee 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -9,10 +9,9 @@ Mathieu Dutour asin.c, atan.c and gamma.c
Vincent Lefèvre Main author
David Daney Hyperbolic and inverse hyperbolic functions, base-2
and base-10 exponential and logarithm, factorial
-Patrick Pélissier Working on low-precision optimizations
-Laurent Fousse Original version of sum.c.
+Patrick Pélissier Main author
+Laurent Fousse Original version of sum.c
All authors are included in the MPFR mailing-list <mpfr@loria.fr>.
This is the preferred way to contact us. For further information, please
-look at the MPFR web page <http://www.mpfr.org/> or
-<http://www.loria.fr/projets/mpfr/>.
+look at the MPFR web page <http://www.mpfr.org/>.
diff --git a/BUGS b/BUGS
index edb69016d..8021e4e4b 100644
--- a/BUGS
+++ b/BUGS
@@ -1,4 +1,4 @@
-Copyright 1999, 2001, 2002, 2003 Free Software Foundation.
+Copyright 1999, 2001, 2002, 2003, 2004 Free Software Foundation.
Contributed by the Spaces project, INRIA Lorraine.
This file is part of the MPFR Library.
@@ -24,13 +24,16 @@ Probably many bugs.
Known bugs:
-* The overflows/underflows are not yet implemented in all functions, or
- partially implemented. For instance, mpfr_pow (z, x, y, rnd) fails for
- very small x and some values of y.
+* The overflows/underflows are partially implemented in some functions.
+ For instance, mpfr_pow (z, x, y, rnd) fails for very small x and some
+ values of y.
* The mpfr_set_ld function assumes that the long double type has an
exponent of at most 15 bits.
+* When MPFR is compiled with Visual C++ under MS Windows, some tests may
+ fail, because of the way special IEEE-754 double values are tested.
+
Potential bugs:
* Possible integer overflows on some machines. Some types are used
diff --git a/ChangeLog b/ChangeLog
index d608feb2b..1dcb2ce12 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,444 @@
+2005-02-21 Vincent Lefevre <Vincent.Lefevre@loria.fr>
+
+ * ui_sub.c: Ported mpfr_ui_sub patch to 2.1 branch:
+ Fixed a bug for u == 0 and x == +0 introduced in ui_sub.c 1.23,
+ when 0 was taken into account as a special case: the sign of the
+ result 0 was incorrect. -> Consider the case u == 0 first.
+
+2005-02-16 Vincent Lefevre <Vincent.Lefevre@loria.fr>
+
+ * set.c: Added a comment. (2.1 branch)
+
+ * sub1.c:
+ Ported another fix to the 2.1 branch (bug introduced in 1.31.2.1).
+
+2005-02-15 Vincent Lefevre <Vincent.Lefevre@loria.fr>
+
+ * tan.c: Ported tan fix to 2.1 branch.
+
+2005-02-14 Vincent Lefevre <Vincent.Lefevre@loria.fr>
+
+ * sum.c: Ported latest bug fix to 2.1 branch.
+
+2005-02-02 Vincent Lefevre <Vincent.Lefevre@loria.fr>
+
+ * tests/tui_sub.c, sub1.c: Ported 1.36 patch to the 2.1 branch:
+ Fix bug of sub1 if dest=src2 and src1 >> src2
+
+2005-01-28 Vincent Lefevre <Vincent.Lefevre@loria.fr>
+
+ * rint.c, tests/trint.c:
+ Ported the mpfr_rint fix and test to the 2.1 branch.
+
+2005-01-27 Vincent Lefevre <Vincent.Lefevre@loria.fr>
+
+ * tests/tset.c, tests/tset_d.c, tests/tset_f.c, tests/tset_ld.c, tests/tset_q.c, tests/tset_si.c, tests/tset_str.c, tests/tset_z.c, tests/tsqr.c, tests/tsqrt.c, tests/tsub.c, tests/tsub1sp.c, tests/tsum.c, tests/tui_div.c, tests/tui_pow.c, tests/tzeta.c, tests/tatan.c, tests/tcan_round.c, tests/tcbrt.c, tests/tcmp.c, tests/tcmpabs.c, tests/tconst_euler.c, tests/tconst_log2.c, tests/tconst_pi.c, tests/tdiv.c, tests/tdiv_ui.c, tests/teq.c, tests/tests.c, tests/texceptions.c, tests/texp.c, tests/tfactorial.c, tests/tfma.c, tests/tfrac.c, tests/tgeneric.c, tests/tget_d_2exp.c, tests/tget_sj.c, tests/tget_str.c, tests/tgmpop.c, tests/thypot.c, tests/tlog.c, tests/tmul.c, tests/tmul_ui.c, tests/tout_str.c, tests/toutimpl.c, tests/tpow.c, tests/tpow3.c, tests/trint.c, tests/tabs.c, tests/tacos.c, tests/tadd.c, tests/tadd1sp.c, tests/tadd_ui.c, tests/tasin.c:
+ Added missing casts for g++ (2.1 branch).
+
+2005-01-21 Vincent Lefevre <Vincent.Lefevre@loria.fr>
+
+ * strtofr.c, sum.c:
+ Fixed bug with TMP_MARK (doesn't occur with alloca) (2.1 branch).
+ [strtofr.c:1.10, sum.c:1.5]
+
+ * tests/tests.c, tests/trint.c:
+ Forgot to include some headers conditionally in tests (2.1 branch).
+ [tests/tests.c:1.36, tests/trint.c:1.21]
+
+ * sum.c: Fixed bug in cases n <= 1 (2.1 branch). [sum.c:1.8-1.9]
+
+ * sub1.c:
+ Fixed a huge performance problem in corner cases (2.1 branch).
+ [sub1.c:1.33-1.35]
+
+ * mpfr.h: Fixed a clash with ncurses preventing from compiling programs
+ including term.h then mpfr.h (2.1 branch).
+
+ * mpfr-longlong.h:
+ Updated longlong.h from GMP 4.1.4 (problem with opteron) (2.1 branch).
+ [mpfr-longlong.h:1.2]
+
+ * get_str.c, mpn_exp.c:
+ Bugs fixed in get_str, in particular for huge exponents (2.1 branch).
+ [get_str.c:1.83, mpn_exp.c:1.6]
+
+ * configure.in: Better way to detect the GMP library (2.1 branch).
+
+2004-11-18 Vincent Lefevre <Vincent.Lefevre@loria.fr>
+
+ * mpfr.texi:
+ Fix (2.1 branch): GMP -> MPFR Copying Conditions (noted by Patrick).
+
+ * mpfr.texi:
+ In HTML, suppress the non-existing link to GMP (2.1 branch).
+
+2004-11-03 Vincent Lefevre <Vincent.Lefevre@loria.fr>
+
+ * ChangeLog: Update (2.1 branch).
+
+ * mpfr.texi: Updated month: October -> November (2.1 branch).
+
+ * configure.in:
+ [2.1 branch] Modified an error message, since the code checking for
+ GMP library hadn't been modified in the branch.
+
+2004-10-27 Vincent Lefevre <Vincent.Lefevre@loria.fr>
+
+ * acinclude.m4: Updated copyright line.
+
+ * BUGS: Added a bug and updated copyright line.
+
+ * mpfr-impl.h, set_d.c:
+ Removed the definitions of DBL_POS_INF/DBL_NEG_INF/DBL_NAN for
+ Visual C++ as they were incorrect. Modified DOUBLE_ISINF(x) so
+ that infinities are no longer used (this should fix a part of
+ the problem for Visual C++). If IEEE 754 is not supported, one
+ should probably use the standard INFINITY macro instead of
+ (1.0/0.0), since (1.0/0.0) is specific to IEEE 754.
+
+ * acinclude.m4, tests/tests.c:
+ Applied patch by Steve M. Robbins for non-IRIX MIPS systems
+ (originally for MPFR 2.0.3).
+
+2004-10-26 Vincent Lefevre <Vincent.Lefevre@loria.fr>
+
+ * tests/tadd1sp.c, tests/tsub1sp.c: Reformatted the code.
+
+ * tests/tsub1sp.c, tests/ttanh.c, tests/tset_ld.c, tests/tset_si.c, tests/tset_str.c, tests/tset_z.c, tests/tround_prec.c, tests/tset.c, tests/tset_exp.c, tests/trint.c, tests/trandom.c, tests/tlog.c, tests/tmul.c, tests/tmul_ui.c, tests/texp2.c, tests/tgamma.c, tests/tcosh.c, tests/tdiv.c, tests/tests.c, tests/texceptions.c, tests/texp.c, tests/tcos.c, tests/tacos.c, tests/tadd1sp.c, tests/tasin.c, tests/tatan.c, mpfr-test.h:
+ Replaced mpfr_set_emin/emax by set_emin/emax in tests to check
+ the return value; defined set_emin/emax in "tests/tests.c".
+ Fix: added missing #include <string.h> in "tests/tests.c".
+ Removed variable names in prototypes in "mpfr-test.h".
+
+2004-10-22 Vincent Lefevre <Vincent.Lefevre@loria.fr>
+
+ * tests/mpf_compat.h: Reformatted the code -> GNU style.
+
+ * ChangeLog: Update.
+
+2004-10-22 Patrick Pelissier <Patrick.Pelissier@loria.fr>
+
+ * tests/tests.c:
+ Declaration of "tests_rand_start" and "tests_rand_end" with the same storage class specifier
+ in tests.c (static missing line 65 and 109).
+
+2004-10-21 Vincent Lefevre <Vincent.Lefevre@loria.fr>
+
+ * strtofr.c:
+ Bug fixed: cast to unsigned char instead of int for isspace (no,
+ these are not "psycho" systems, just systems with signed chars).
+ Untabified the source.
+
+2004-10-20 Patrick Pelissier <Patrick.Pelissier@loria.fr>
+
+ * configure.in: Improve ICC CFLAGS by removins meaningless warnings.
+
+ * strtofr.c: Remove some warnings on some "psycho" systems.
+
+ * README.dev: Update the chapter "Make a release".
+
+ * mpfr-test.h, tests/mpf_compat.h, tests/tests.c, tests/tinp_str.c:
+ Fix bug when you build MPFR outside source directory.
+ Add function src_fopen to open a file in the source directory, which
+ may be different from the current directory.
+
+ * INSTALL: Fix a typo.
+
+2004-10-19 Vincent Lefevre <Vincent.Lefevre@loria.fr>
+
+ * mpfr.texi: Another correction (English).
+
+ * mpfr.texi: Minor correction.
+
+2004-10-19 Patrick Pelissier <Patrick.Pelissier@loria.fr>
+
+ * NEWS: Update NEWS to reflect the change in mpfr_set_str.
+
+ * mpfr.texi, set_str.c, tests/tset_str.c:
+ Update mpfr_set_str to be much more like strtofr.
+ Update the documentation to reflect the changes.
+
+2004-10-19 Paul Zimmermann <Paul.Zimmermann@loria.fr>
+
+ * mpfr.texi: changed contributors section
+
+2004-10-19 Patrick Pelissier <Patrick.Pelissier@loria.fr>
+
+ * NEWS: Add a line about binary compatibility.
+
+2004-10-19 Paul Zimmermann <Paul.Zimmermann@loria.fr>
+
+ * mpfr.texi: changed "contributors" section
+
+ * mul.c: changed rights (remove executable permission)
+
+2004-10-18 Vincent Lefevre <Vincent.Lefevre@loria.fr>
+
+ * mpfr.texi: Misc corrections:
+ + spelling mistakes
+ + consistency: in direction @var{rnd} -> in the direction @var{rnd}
+ + @code{NULL} pointer -> null pointer (as in the C standard)
+ + in the example for mpfr_inits2 / mpfr_clears: NULL -> (void *) 0
+ as NULL isn't necessarily a pointer.
+
+2004-10-18 Patrick Pelissier <Patrick.Pelissier@loria.fr>
+
+ * BUGS, README: Update
+
+ * tests/tstrtofr.c, set_str.c, strtofr.c, tests/tset_str.c, mpfr.h, mpfr.texi:
+ Change "unsigned int" to "int" for base in proto of strtofr.
+ Change set_str to use strtofr (Fix a bug too).
+ Limit base to 36 in strtofr (since get_str is limited to 36).
+ Update documentation to reflect the changes.
+ mpfr_get_d1 is moved to section internal in the documentation.
+ Update the tests.
+
+ * mpfr-impl.h: Hard code NAN, +INF and -INF values for MVC.
+
+ * tests/mpf_compat.h, tests/tout_str.c:
+ Fix problem on systems where "/dev/null" doesn't exist.
+
+2004-10-16 Vincent Lefevre <Vincent.Lefevre@loria.fr>
+
+ * AUTHORS, mpfr.texi: Misc corrections.
+
+2004-10-15 Vincent Lefevre <Vincent.Lefevre@loria.fr>
+
+ * README.dev: Updated the section "To make a release".
+
+ * ChangeLog: Update.
+
+ * NEWS: Update for 2.1.0.
+
+2004-10-13 Vincent Lefevre <Vincent.Lefevre@loria.fr>
+
+ * README.dev:
+ Added a comment about autoreconf and a bug in Debian (now fixed).
+
+2004-10-12 Patrick Pelissier <Patrick.Pelissier@loria.fr>
+
+ * INSTALL: Add a note about Windows 64.
+
+2004-10-11 Patrick Pelissier <Patrick.Pelissier@loria.fr>
+
+ * mpfr.texi: Update documentation.
+
+ * INSTALL: Improve Windows installation.
+
+ * README.dev: Add a line about "near" and "far".
+
+2004-10-07 Patrick Pelissier <Patrick.Pelissier@loria.fr>
+
+ * acinclude.m4, configure.in, tests/tget_str.c:
+ Add support for ".lib" since it seems to work.
+ Display GMP version inside the configure.
+
+2004-10-05 Paul Zimmermann <Paul.Zimmermann@loria.fr>
+
+ * tests/tget_str.c: added one new test
+
+2004-10-04 Vincent Lefevre <Vincent.Lefevre@loria.fr>
+
+ * tests/tget_str.c: Added worst cases.
+
+2004-10-02 Paul Zimmermann <Paul.Zimmermann@loria.fr>
+
+ * tests/tset_str.c: added new tests (worst-case)
+
+2004-10-01 Paul Zimmermann <Paul.Zimmermann@loria.fr>
+
+ * tests/tget_str.c: added new worst-cases (directed rounding)
+
+ * TODO: added new function to implement (dilog)
+
+2004-09-30 Paul Zimmermann <Paul.Zimmermann@loria.fr>
+
+ * get_str.c: fixed bug in get_str_aux when one extra digit
+
+2004-09-30 Vincent Lefevre <Vincent.Lefevre@loria.fr>
+
+ * mpfr.h, mpfr.texi, rint.c, tests/trint.c:
+ Added functions mpfr_rint_round, mpfr_rint_trunc, mpfr_rint_ceil,
+ mpfr_rint_floor.
+
+2004-09-30 Patrick Pelissier <Patrick.Pelissier@loria.fr>
+
+ * tests/tget_str.c: Add new test (One failed).
+
+2004-09-30 Vincent Lefevre <Vincent.Lefevre@loria.fr>
+
+ * get_sj.c:
+ The cast to uintmax_t wasn't really useful, so I removed it.
+ Added a comment.
+
+ * get_sj.c: The real fix for sizeof(intmax_t) == sizeof(mp_limb_t).
+
+2004-09-30 Patrick Pelissier <Patrick.Pelissier@loria.fr>
+
+ * get_sj.c: Fix a bug if sizeof(intmax_t) == sizeof(mp_limb_t)
+
+2004-09-29 Paul Zimmermann <Paul.Zimmermann@loria.fr>
+
+ * tests/tget_str.c: added worst-case
+
+2004-09-29 Patrick Pelissier <Patrick.Pelissier@loria.fr>
+
+ * TODO, cmp.c, cmp_abs.c, cmp_d.c, cmp_si.c, cmp_ui.c, mpfr.texi, tests/tcmp.c, tests/tcmp_d.c, tests/tcmp_ld.c, tests/tcmp_ui.c, tests/tcmpabs.c:
+ cmp(x,y) if x=NAN or y=NAN returns 0 and erange flag.
+
+ * NEWS, mpfr.texi:
+ Update documentation and NEWS to reflect new functions
+ and functionnality.
+
+ * get_z.c, strtofr.c: Improve assertion.
+
+ * tests/tset_si.c, exceptions.c, get_si.c, get_sj.c, get_ui.c, get_uj.c, mpfr-impl.h, set_sj.c, set_uj.c, tests/texceptions.c, tests/tget_sj.c, tests/tset_sj.c:
+ Add mpfr_clear_erangeflag and mpfr_erangeflag_p.
+ Add test for theses two functions.
+ mpfr_get_[s/u][i/j] have a deterministic behavior in case of OVERFLOW.
+ (Return the MINIMUM or the MAXIMUM in the current type, and set
+ ERANGE_flag).
+
+ * Makefile.am, fits_intmax.c, fits_uintmax.c, mpfr.h, tests/tfits.c:
+ Add mpfr_uintmax_p and mpfr_intmax_p.
+
+ * TODO, INSTALL: Update INSTALL about C++
+ Update TODO and VERSION.
+
+ * mpfr-impl.h, mpfr.texi, mpfr.h:
+ Move mpfr_inits from mpfr-impl to mpfr.h.
+ Add doc too.
+
+2004-09-28 Patrick Pelissier <Patrick.Pelissier@loria.fr>
+
+ * get_sj.c, get_uj.c: Reindent the sources (again).
+
+ * mpn_exp.c:
+ Fix how to detect overflow so that it can be build with GCC -ftrapv
+ option without any bugs (In the previous code, the overflow was
+ detected afterwards, whereas, now, it is detected before).
+ Fix also another real problem of overflow (Addition of two signed integers).
+
+ * div.c: Rename this variable again.
+
+ * div.c:
+ Replace variable 'near' to 'the_real_near' since MSVC incorreclty
+ recognize "far" and "near" as obsolete keywords (100% incorrect, and
+ clearly MSVC fault but it doesn't cost many things to change the name).
+
+2004-09-27 Patrick Pelissier <Patrick.Pelissier@loria.fr>
+
+ * mpfr.texi: Fix typo in the documentation about get_ functions.
+
+ * get_sj.c, get_uj.c: Retab the sources.
+
+2004-09-27 Vincent Lefevre <Vincent.Lefevre@loria.fr>
+
+ * NEWS:
+ Added mpfr_get_uj and mpfr_get_sj in the changes 2.0.3 -> 2.1.0.
+
+ * TODO: Added an item about the future MPFR_FLAGS_ERANGE flag.
+
+ * Makefile.am, get_sj.c, get_uj.c, mpfr.h, mpfr.texi, tests/Makefile.am, tests/tget_sj.c:
+ New functions mpfr_get_sj and mpfr_get_uj, with tests.
+
+2004-09-27 Patrick Pelissier <Patrick.Pelissier@loria.fr>
+
+ * set_sj.c: Remove MPFR_NEED_LONGLONG_H macro.
+
+2004-09-26 Vincent Lefevre <Vincent.Lefevre@loria.fr>
+
+ * set_sj.c: Added a cast to avoid an integer overflow.
+
+2004-09-24 Vincent Lefevre <Vincent.Lefevre@loria.fr>
+
+ * get_si.c: Fixed integer overflow.
+
+ * get_si.c: Fixed bugs (like those in mpfr_get_ui).
+
+ * README.dev:
+ The standard autoreconf script should now be used instead of prepare.
+
+2004-09-24 Paul Zimmermann <Paul.Zimmermann@loria.fr>
+
+ * get_ui.c: forgot to check for 0
+
+ * get_ui.c: now use mpfr_rint()
+
+2004-09-24 Patrick Pelissier <Patrick.Pelissier@loria.fr>
+
+ * mpfr.texi: Update doc of mpfr_get_str (Minimum space is 7).
+
+2004-09-24 Paul Zimmermann <Paul.Zimmermann@loria.fr>
+
+ * get_ui.c, tests/tset_si.c: fixed double-rounding bug in get_ui
+
+2004-09-23 Patrick Pelissier <Patrick.Pelissier@loria.fr>
+
+ * mpf2mpfr.h: Prevent from multiple inclusion.
+ mpf_init inits to 0 rather than NAN.
+
+ * mpfr.h: Fix some tiny problems.
+
+2004-09-23 Paul Zimmermann <Paul.Zimmermann@loria.fr>
+
+ * TODO: added item on rounding to odd
+
+2004-09-21 Patrick Pelissier <Patrick.Pelissier@loria.fr>
+
+ * strtofr.c: Fix a bug in FreeBsd 5.20 / Alpha / Gcc 3.3.3.
+ Nor a MPFR bug, but add some code to avoid it.
+
+ * strtofr.c, tests/tstrtofr.c: Add a new test and clarify a comment.
+
+ * strtofr.c: Update Assertion for pow2.
+
+2004-09-20 Patrick Pelissier <Patrick.Pelissier@loria.fr>
+
+ * NEWS: Update NEWS.
+
+ * TODO: Update TODO due to new function mpfr_strtofr
+
+ * configure.in, get_d.c, mpfr-impl.h, mpfr.h, set_d.c, strtofr.c, tests/memory.c, tests/tdiv.c, tests/tests.c, tests/tget_str.c, tests/trint.c, tests/tset_d.c, tests/tset_q.c, tests/tset_str.c, tests/tstrtofr.c:
+ Add ICC detection && support.
+ Remove some potential warnings in the test files.
+
+ * Makefile.am, mpfr.texi, strtofr.c, tests/Makefile.am, tests/tstrtofr.c:
+ Add mpfr_strtofr function.
+ Add mpfr_strtofr test file.
+ Add mpfr_strtofr documentation.
+
+ * configure.in: Improve GMP.h vs libgmp.a version checking.
+
+2004-09-17 Paul Zimmermann <Paul.Zimmermann@loria.fr>
+
+ * TODO: added one entry (new function 1/sqrt(x))
+
+2004-09-17 Patrick Pelissier <Patrick.Pelissier@loria.fr>
+
+ * acinclude.m4, configure.in, tests/Makefile.am:
+ Use LIBS instead of LDADD for libraries (GMP).
+
+ * configure.in: Min GMP version is 4.1.0 now.
+
+2004-09-16 Patrick Pelissier <Patrick.Pelissier@loria.fr>
+
+ * configure.in:
+ Add a check if both gmp.h and libgmp.a have the same version.
+
+ * mpfr-impl.h: Fix a typo.
+
+2004-09-15 Patrick Pelissier <Patrick.Pelissier@loria.fr>
+
+ * tests/tset_str.c: Add a forgotten regression test "1.2.3"
+
+2004-09-15 Vincent Lefevre <Vincent.Lefevre@loria.fr>
+
+ * config.sub, config.guess:
+ Update from the autotools-dev Debian package.
+
+ * ChangeLog: Update.
+
2004-09-14 Patrick Pelissier <Patrick.Pelissier@loria.fr>
* mpfr-impl.h: Add 2 new macros for handling correctly overflow.
diff --git a/INSTALL b/INSTALL
index 8866341d1..092816f01 100644
--- a/INSTALL
+++ b/INSTALL
@@ -33,7 +33,7 @@ install recent versions of some utilities such as texinfo.
Building MPFR with internal GMP header files
============================================
- MPFR built with internal GMP header files is a few faster,
+ MPFR built with internal GMP header files is a bit faster,
so you may want to build it with them. Just do this in step 1:
./configure --with-gmp-build=GMPBUILD
@@ -82,6 +82,8 @@ In case of problem
On some architectures, try with `gmake` instead of `make`.
+ Try to build MPFR with/without GMP internal files.
+
If you can't solve your problem, you could contact us at mpfr@loria.fr,
indicating the machine and operating system used (uname -a), the compiler
and version used (gcc -v if you use gcc), the compile options used if any,
@@ -92,8 +94,8 @@ In case of problem
the test suite: C and C++ are not the same language!
You should use a C compiler instead.
-Notes on Windows
-================
+Notes on Windows 32
+===================
1 - we advise to use mingw (http://www.mingw.org/), which is simpler and
less demanding than cygwin. Contrary to Cygwin, it also provides native
@@ -104,11 +106,22 @@ Notes on Windows
2 - if you just want to make a binary with gcc, there is nothing to do:
gmp, mpfr and the program compile exactly as under Linux.
-3 - if you want to make libraries to work under a native Windows compiler
+3 - if you want to make libraries to work under another Windows compiler
like Visual C / C++, the "trick" is that the unix-like *.a files created
by gcc are entirely compatible with the Windows *.lib files. So you just
have to rename the *.a files into *.lib.
With gmp-4.1.3, the only remaining problem seems to be the "alloca" calls
in gmp. Configuring gmp and mpfr with --enable-alloca=malloc-reentrant
- should work.
+ should work (If you build MPFR with gmp internal files).
+
+ Or you could add the library
+ "$MINGWIN$/lib/gcc-lib/mingw32/$VERSION$/libgcc.a"
+ to your project: it contains all the extra-functions needed by a program
+ compiled by GCC (Division of 64 bits integer, bcopy, alloca, ...).
+ Of course, include it iff your compiler is not GCC.
+
+Notes on Windows 64
+===================
+
+ MPFR has not been tested on Windows 64.
diff --git a/NEWS b/NEWS
index 5844ba94d..454ec3519 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
-Copyright 2000, 2001, 2002, 2003, 2004 Free Software Foundation.
+Copyright 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation.
Contributed by the Spaces project, INRIA Lorraine.
This file is part of the MPFR Library.
@@ -20,6 +20,10 @@ MA 02111-1307, USA.
##############################################################################
+Changes from version 2.1.0 to version 2.1.1:
+- Better way to detect the GMP library.
+- Bug fixes.
+
Changes from version 2.0.3 to version 2.1.0:
- Bug fixes.
- new functions mpfr_strtofr, mpfr_set_uj, mpfr_set_sj, mpfr_set_ui_2exp,
@@ -30,7 +34,8 @@ Changes from version 2.0.3 to version 2.1.0:
mpfr_get_default_rounding_mode, mpfr_get_emin_min, mpfr_get_emin_max,
mpfr_get_emax_min, mpfr_get_emax_max, mpfr_inits, mpfr_inits2, mpfr_clears,
mpfr_fits_intmax_p, mpfr_fits_uintmax_p, mpfr_clear_erangeflag,
- mpfr_erangeflag_p.
+ mpfr_erangeflag_p, mpfr_rint_round, mpfr_rint_trunc, mpfr_rint_ceil,
+ mpfr_rint_floor.
- new macros MPFR_DECL_INIT, MPFR_VERSION, MPFR_VERSION_NUM,
MPFR_VERSION_MAJOR, MPFR_VERSION_MINOR, MPFR_VERSION_PATCHLEVEL.
- improved documentation.
@@ -39,7 +44,10 @@ Changes from version 2.0.3 to version 2.1.0:
- It handles correctly non IEEE-754 double.
- GMP internal files are not needed to install MPFR.
- It is faster with low-precision floatting point.
-- New global flag: ERANGE_FLAG
+- New global flag: ERANGE_FLAG.
+- Binary incompatible with previous versions, but API compatible.
+- mpfr_set_str doesn't allow anymore "@NAN@garbagechar" and "@INF@garbagechar",
+ allows base 0 (detection of the base), prefix (0x, 0b), leading whitespace.
Changes from version 2.0.2 to version 2.0.3:
- Bug fixes.
diff --git a/README b/README
index 2180ce51a..1f11ca010 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-Copyright 2000, 2001, 2002, 2003 Free Software Foundation.
+Copyright 2000, 2001, 2002, 2003, 2004 Free Software Foundation.
Contributed by the Spaces project, INRIA Lorraine.
This file is part of the MPFR Library.
@@ -45,7 +45,6 @@ mkinst* - auxiliary installation file
mpf2mpfr.h - header file for compatibility with MPF
mpfr.h - external header file for MPFR
mpfr-impl.h - internal header file for MPFR
-mpfr-math.h - another internal header file for MPFR
mpfr-test.h - header file for test files
mpfr.info - info file for MPFR
mpfr.texi - texinfo documentation for MPFR
@@ -55,6 +54,7 @@ texinfo.tex - TeX macros to handle mpfr.texi
You can get the latest source code by CVS:
- cvs -d :pserver:cvs@cvs-sop.inria.fr:/CVS/spaces checkout mpfr
+ cvs -d :pserver:cvs@cvs-sop.inria.fr:/CVS/spaces login
+ cvs -d :pserver:cvs@cvs-sop.inria.fr:/CVS/spaces -z3 checkout -P mpfr
(empty password). CVS users should read the file "README.dev".
diff --git a/README.dev b/README.dev
index 4b3ba37cd..80217459b 100644
--- a/README.dev
+++ b/README.dev
@@ -5,8 +5,9 @@ To compile source code obtained from CVS, you need some GNU development
utilities: aclocal, autoheader, automake, autoconf 2.50 (at least). As
some files like "configure" are not part of the CVS repository, you
first need to run "autoreconf"; if you have both autoconf 2.13 and 2.50
-installed, you may need to run "autoreconf" a second time. Then you can
-run "configure" in the usual way (see the INSTALL file).
+installed and use a wrapper, you may need to run "autoreconf" a second
+time (as with old Debian packages, due to a bug in the wrapper). Then
+you can run "configure" in the usual way (see the INSTALL file).
If for some reason, this doesn't work, there's still the old way: run
the "prepare" script to generate these files; as the "prepare" script
@@ -52,21 +53,23 @@ with new systems.
To make a release (for the MPFR team):
1) Check the version and update the date in mpfr.texi.
- 2) Update the ChangeLog file (using a recent version of rcs2log,
+ 2) Update the NEWS file.
+ 3) Update the ChangeLog file (using a recent version of rcs2log,
directly or with emacs), e.g. rcs2log > ChangeLog.2 and edit
ChangeLog to insert ChangeLog.2 at the beginning and remove
the duplicated lines.
- 3) Update the NEWS file.
- 4) Generate the release version with "make dist".
- 5) Test the release version on different machines, with and without
+ 4) Fix the file permissions that have been broken by CVS.
+ 5) Generate the release version with "make dist".
+ 6) Test the release version on different machines, with and without
the --disable-alloca configure option (or compile gmp with
--enable-alloca=debug), with and without -DXDEBUG in $CFLAGS,
with and without gmp internal files, with and without gmp built
- as a shared library.
- 6) If there is no problem, add a tag to the CVS corresponding to the
+ as a shared library, with and without srcdir equals to objdir
+ (../mpfr/configure --srcdir=/users/spaces/pelissip/mpfr/).
+ 7) If there is no problem, add a tag to the CVS corresponding to the
release, e.g. mpfr-2-0-1-rel for mpfr 2.0.1 (note that the periods
are replaced by dashes): cvs tag mpfr-2-0-1-rel
- 7) Update the version with the update-version script to indicate the
+ 8) Update the version with the update-version script to indicate the
next version.
A branch may be created first (e.g. with "cvs tag -b mpfr-2-0-2-branch")
@@ -74,7 +77,7 @@ to allow new features to be committed to the trunk.
===========================================
-To check the coverage of the test suite (for the MPFR team),
+To check the coverage of the test suite (for the MPFR team),
you can use gcov (with GCC):
1. Clean MPFR:
make clean
@@ -91,7 +94,7 @@ you can use gcov (with GCC):
===========================================================================
List of the used macros for building MPFR:
-
+
+ HAVE_STRCASECMP: Define if the system supports 'strcasecmp' function.
+ HAVE_STRNCASECMP: Define if the system supports 'strncasecmp' function.
@@ -111,7 +114,7 @@ List of the used macros for building MPFR:
+ HAVE_LDOUBLE_IEEE_QUAD_BIG: IEEE quad, big endian.
+ XDEBUG: Use generic 'double' code instead of IEEE specific one.
- The IEEE code for double needs GMP internal files.
+ The IEEE code for double needs GMP internal files.
+ WANT_ASSERT: Define if we want to turn on the assertions.
+ MPFR_EXP_CHECK: Define if we want to check the exp field.
@@ -124,7 +127,7 @@ List of the used macros for building MPFR:
List of the used macros for checking MPFR:
-+ MPFR_HAVE_FESETROUND: Define if the fesetround function is defined
++ MPFR_HAVE_FESETROUND: Define if the fesetround function is defined
(and in header fenv.h).
+ HAVE_DENORMS: Define if denormalized floats work.
+ HAVE_SYS_TIME_H: Define if the header sys/time.h is usuable.
@@ -149,3 +152,8 @@ produce illegal codes with the first form.
The GNU Coding standards can be read at:
http://www.gnu.org/prep/standards_toc.html
+
+===========================================================================
+
+Don't use "near" and "far" as variable names since they are "Keywords"
+for some C compiler (Old DOS compiler).
diff --git a/VERSION b/VERSION
index 7ec1d6db4..3e3c2f1e5 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.1.0
+2.1.1
diff --git a/acinclude.m4 b/acinclude.m4
index 952e2256b..f5ef1d882 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -1,6 +1,6 @@
dnl MPFR specific autoconf macros
-dnl Copyright 2000, 2002, 2003 Free Software Foundation.
+dnl Copyright 2000, 2002, 2003, 2004 Free Software Foundation.
dnl Contributed by the Spaces project, INRIA Lorraine.
dnl
dnl This file is part of the MPFR Library.
@@ -40,7 +40,12 @@ then
then
LIBS="$LIBS $1/lib$2.so"
else
- AC_MSG_ERROR($1/lib$2.a/so not found)
+ if test -r "$1/lib$2.lib"
+ then
+ LIBS="$LIBS $1/lib$2.lib"
+ else
+ AC_MSG_ERROR($1/lib$2.a/so/lib not found)
+ fi
fi
fi
AC_MSG_RESULT(yes)
@@ -146,6 +151,13 @@ esac
#
AC_CHECK_HEADERS(sys/fpu.h)
+AC_CHECK_TYPE( [union fpc_csr], AC_DEFINE(HAVE_FPC_CSR), ,
+[
+#if HAVE_SYS_FPU_H
+# include <sys/fpu.h>
+#endif
+])
+
dnl Check for fesetround
AC_CACHE_CHECK([for fesetround], mpfr_cv_have_fesetround, [
saved_LIBS="$LIBS"
diff --git a/configure.in b/configure.in
index c547b9d93..4aa793f8b 100644
--- a/configure.in
+++ b/configure.in
@@ -60,7 +60,7 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#endif
]], [[]])],[AC_MSG_RESULT(yes)
GCC=
- CFLAGS="-pc64 -fp_port -mp $CFLAGS"
+ CFLAGS="-pc64 -fp_port -mp -wd1572 -wd265 -wd186 -wd239 $CFLAGS"
],[AC_MSG_RESULT(no)])
dnl If compiler is gcc, then use some specific flags.
@@ -155,7 +155,32 @@ if test -f confdefs.h; then
mv confdefs.tmp confdefs.h
fi
-AC_MY_LIBS($with_gmp_lib, gmp)
+dnl AC_CHECK_LIB doesn't do what we want
+AC_MSG_CHECKING(for GMP library)
+if test -r "$with_gmp_lib/libgmp.a"; then
+ LIBS="$with_gmp_lib/libgmp.a $LIBS"
+elif test -r "$with_gmp_lib/libgmp.so"; then
+ LIBS="$with_gmp_lib/libgmp.so $LIBS"
+elif test -r "$with_gmp_lib/libgmp.lib"; then
+ LIBS="$with_gmp_lib/libgmp.lib $LIBS"
+else
+ if test -d "$with_gmp_lib"; then
+ LDFLAGS="-L$with_gmp_lib $LDFLAGS"
+ fi
+ LIBS="-lgmp $LIBS"
+fi
+dnl FIXME: If AC_RUN_IFELSE failed try with AC_LINK_IFELSE?
+AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#include "gmp.h"
+int main() { return !gmp_version; }
+ ]])], [
+ AC_MSG_RESULT(yes)
+ ], [
+ AC_MSG_RESULT(no)
+ AC_MSG_ERROR(libgmp not found)
+ ], [
+ AC_MSG_RESULT([can't test])
+ ])
dnl Check for corresponding 'gmp.h' and libgmp.a
AC_MSG_CHECKING(if gmp.h version and libgmp version are the same)
@@ -168,14 +193,15 @@ int main()
char buffer[100];
if (__GNU_MP_VERSION_PATCHLEVEL != 0)
sprintf (buffer, "%d.%d.%d", __GNU_MP_VERSION, __GNU_MP_VERSION_MINOR,
- __GNU_MP_VERSION_PATCHLEVEL);
+ __GNU_MP_VERSION_PATCHLEVEL);
else
sprintf (buffer, "%d.%d", __GNU_MP_VERSION, __GNU_MP_VERSION_MINOR);
+ printf ("(%s/%s) ", buffer, gmp_version);
return (strcmp (buffer, gmp_version) != 0) ? 1 : 0;
}
-], AC_MSG_RESULT(yes),
+], AC_MSG_RESULT(yes),
[AC_MSG_RESULT(no)
- AC_MSG_ERROR(['gmp.h' and 'libgmp' have different versions! you have to properly reinstall GMP.])],
+ AC_MSG_ERROR(['gmp.h' and 'libgmp' have different versions, or (on some platforms) libgmp couldn't be found! You have to properly reinstall GMP.])],
AC_MSG_RESULT([can't test])
)
diff --git a/exp.c b/exp.c
index 4682896b8..56fbb9ce9 100644
--- a/exp.c
+++ b/exp.c
@@ -1,6 +1,6 @@
/* mpfr_exp -- exponential of a floating-point number
-Copyright 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation.
+Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation.
Contributed by the Spaces project.
This file is part of the MPFR Library.
@@ -82,9 +82,9 @@ mpfr_exp (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode)
{
int signx = MPFR_SIGN(x);
+ MPFR_SET_POS(y);
if (MPFR_IS_NEG_SIGN(signx) && (rnd_mode == GMP_RNDD))
{
- MPFR_SET_POS(y);
mpfr_setmax (y, 0); /* y = 1 - epsilon */
return -1;
}
diff --git a/get_str.c b/get_str.c
index c3ed46c28..f9540464f 100644
--- a/get_str.c
+++ b/get_str.c
@@ -376,14 +376,22 @@ mpfr_get_str_aux (char *const str, mp_exp_t *const exp, mp_limb_t *const r,
static mp_exp_t
mpfr_get_str_compute_g (int beta, mp_exp_t e)
{
- double g0, g1;
+ double g0, g1, de;
mp_exp_t g;
- g0 = (double) e * log_b2[beta - 2];
- g1 = (double) e * log_b2_low[beta - 2];
+ de = (double) e;
+ g0 = de * log_b2[beta - 2];
+ g1 = de * log_b2_low[beta - 2];
+ if (de > 9007199254740992.0 || de < -9007199254740992.0)
+ /* can happen on 64-bit machines */
+ {
+ mp_exp_t low_e = e - (mp_exp_t) de;
+ g1 += (double) low_e * log_b2[beta - 2];
+ }
g = (mp_exp_t) mpfr_ceil_double (g0);
g0 -= (double) g;
- return g + (mp_exp_t) mpfr_ceil_double (g0 + g1);
+ g += (mp_exp_t) mpfr_ceil_double (g0 + g1);
+ return g;
}
/* prints the mantissa of x in the string s, and writes the corresponding
diff --git a/mpfr-impl.h b/mpfr-impl.h
index 4cc131504..0d2c41124 100644
--- a/mpfr-impl.h
+++ b/mpfr-impl.h
@@ -262,6 +262,16 @@ typedef unsigned long int mpfr_uexp_t;
#endif
#define MPFR_LIMBS_PER_DOUBLE ((IEEE_DBL_MANT_DIG-1)/BITS_PER_MP_LIMB+1)
+/* Visual C++ doesn't support +1.0/.00, -1.0/0.0 and 0.0/0.0
+#if defined(_MSC_VER) && defined(_WIN32) && (_MSC_VER >= 1200)
+# define DBL_POS_INF ((double)0x7ff0000000000000ull)
+# define DBL_NEG_INF ((double)0xfff0000000000000ull)
+# define DBL_NAN ((double)0x7ff8000000000000ull)
+#else */
+#define DBL_POS_INF ((double) 1.0/0.0)
+#define DBL_NEG_INF ((double)-1.0/0.0)
+#define DBL_NAN ((double) 0.0/0.0)
+
/* for x of type ieee_double_extract */
#if _GMP_IEEE_FLOATS
typedef union ieee_double_extract Ieee_double_extract;
@@ -274,13 +284,10 @@ typedef union ieee_double_extract Ieee_double_extract;
((((Ieee_double_extract *)&(x))->s.manl != 0) || \
(((Ieee_double_extract *)&(x))->s.manh != 0)))
#else
-# define DOUBLE_ISINF(x) (((x)==((double)+1.0/0.0))||((x)==((double)-1.0/0.0)))
-# define DOUBLE_ISNAN(x) ((x)!=(x))
+# define DOUBLE_ISINF(x) ((x) > DBL_MAX || (x) < -DBL_MAX)
+# define DOUBLE_ISNAN(x) ((x) != (x))
#endif
-#define DBL_POS_INF (1.0/0.0)
-#define DBL_NEG_INF (-1.0/0.0)
-#define DBL_NAN (0.0/0.0)
/* macros for long doubles */
diff --git a/mpfr-longlong.h b/mpfr-longlong.h
index 5e2a119c8..9d875aaa7 100644
--- a/mpfr-longlong.h
+++ b/mpfr-longlong.h
@@ -1,7 +1,7 @@
/* longlong.h -- definitions for mixed size 32/64 bit arithmetic.
-Copyright 1991, 1992, 1993, 1994, 1996, 1997, 1999, 2000, 2001, 2002 Free
-Software Foundation, Inc.
+Copyright 1991, 1992, 1993, 1994, 1996, 1997, 1999, 2000, 2001, 2002, 2003
+Free Software Foundation, Inc.
This file is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -94,7 +94,25 @@ MA 02111-1307, USA. */
and is lost.
If any of these macros are left undefined for a particular CPU,
- C macros are used. */
+ C macros are used.
+
+
+ Notes:
+
+ For add_ssaaaa the two high and two low addends can both commute, but
+ unfortunately gcc only supports one "%" commutative in each asm block.
+ This has always been so but is only documented in recent versions
+ (eg. pre-release 3.3). Having two or more "%"s can cause an internal
+ compiler error in certain rare circumstances.
+
+ Apparently it was only the last "%" that was ever actually respected, so
+ the code has been updated to leave just that. Clearly there's a free
+ choice whether high or low should get it, if there's a reason to favour
+ one over the other. Also obviously when the constraints on the two
+ operands are identical there's no benefit to the reloader in any "%" at
+ all.
+
+ */
/* The CPUs come in alphabetical order below.
@@ -183,11 +201,14 @@ long __MPN(count_leading_zeros) _PROTO ((UDItype));
#endif /* _CRAY */
#if defined (__hppa) && W_TYPE_SIZE == 64
-#if defined (__GNUC__)
+/* These macros are for ABI=2.0w. In ABI=2.0n they can't be used, since GCC
+ (3.2) puts longlong into two adjacent 32-bit registers. Presumably this
+ is just a case of no direct support for 2.0n but treating it like 1.0. */
+#if defined (__GNUC__) && ! defined (_LONG_LONG_LIMB)
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("add %4,%5,%1\n\tadd,dc %2,%3,%0" \
: "=r" (sh), "=&r" (sl) \
- : "%rM" (ah), "rM" (bh), "%rM" (al), "rM" (bl))
+ : "rM" (ah), "rM" (bh), "%rM" (al), "rM" (bl))
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("sub %4,%5,%1\n\tsub,db %2,%3,%0" \
: "=r" (sh), "=&r" (sl) \
@@ -269,7 +290,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype, UWtype, UWtype, UWtype *));
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("add %1,%4,%5\n\taddc %0,%2,%3" \
: "=r" (sh), "=&r" (sl) \
- : "%r" (ah), "rI" (bh), "%r" (al), "rI" (bl))
+ : "r" (ah), "rI" (bh), "%r" (al), "rI" (bl))
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("sub %1,%4,%5\n\tsubc %0,%2,%3" \
: "=r" (sh), "=&r" (sl) \
@@ -300,7 +321,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype, UWtype, UWtype, UWtype *));
__asm__ ("add.f\t%1, %4, %5\n\tadc\t%0, %2, %3" \
: "=r" ((USItype) (sh)), \
"=&r" ((USItype) (sl)) \
- : "%r" ((USItype) (ah)), \
+ : "r" ((USItype) (ah)), \
"rIJ" ((USItype) (bh)), \
"%r" ((USItype) (al)), \
"rIJ" ((USItype) (bl)))
@@ -318,7 +339,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype, UWtype, UWtype, UWtype *));
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("adds\t%1, %4, %5\n\tadc\t%0, %2, %3" \
: "=r" (sh), "=&r" (sl) \
- : "%r" (ah), "rI" (bh), "%r" (al), "rI" (bl) __CLOBBER_CC)
+ : "r" (ah), "rI" (bh), "%r" (al), "rI" (bl) __CLOBBER_CC)
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
do { \
if (__builtin_constant_p (al)) \
@@ -456,7 +477,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype));
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("add.w %5,%1\n\taddx %3,%0" \
: "=g" ((USItype)(sh)), "=&g" ((USItype)(sl)) \
- : "%0" ((USItype)(ah)), "g" ((USItype)(bh)), \
+ : "0" ((USItype)(ah)), "g" ((USItype)(bh)), \
"%1" ((USItype)(al)), "g" ((USItype)(bl)))
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("sub.w %5,%1\n\tsubx %3,%0" \
@@ -480,7 +501,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype));
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("add %4,%5,%1\n\taddc %2,%3,%0" \
: "=r" (sh), "=&r" (sl) \
- : "%rM" (ah), "rM" (bh), "%rM" (al), "rM" (bl))
+ : "rM" (ah), "rM" (bh), "%rM" (al), "rM" (bl))
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("sub %4,%5,%1\n\tsubb %2,%3,%0" \
: "=r" (sh), "=&r" (sl) \
@@ -560,7 +581,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype));
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("addl %5,%1\n\tadcl %3,%0" \
: "=r" ((USItype)(sh)), "=&r" ((USItype)(sl)) \
- : "%0" ((USItype)(ah)), "g" ((USItype)(bh)), \
+ : "0" ((USItype)(ah)), "g" ((USItype)(bh)), \
"%1" ((USItype)(al)), "g" ((USItype)(bl)))
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("subl %5,%1\n\tsbbl %3,%0" \
@@ -691,7 +712,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype));
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("addq %5,%1\n\tadcq %3,%0" \
: "=r" ((UDItype)(sh)), "=&r" ((UDItype)(sl)) \
- : "%0" ((UDItype)(ah)), "g" ((UDItype)(bh)), \
+ : "0" ((UDItype)(ah)), "g" ((UDItype)(bh)), \
"%1" ((UDItype)(al)), "g" ((UDItype)(bl)))
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("subq %5,%1\n\tsbbq %3,%0" \
@@ -713,10 +734,12 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype));
__asm__ ("bsrq %1,%0" : "=r" (__cbtmp) : "rm" ((UDItype)(x))); \
(count) = __cbtmp ^ 63; \
} while (0)
+/* bsfq destination must be a 64-bit register, "%q0" forces this in case
+ count is only an int. */
#define count_trailing_zeros(count, x) \
do { \
ASSERT ((x) != 0); \
- __asm__ ("bsfq %1,%0" : "=r" (count) : "rm" ((UDItype)(x))); \
+ __asm__ ("bsfq %1,%q0" : "=r" (count) : "rm" ((UDItype)(x))); \
} while (0)
#endif /* x86_64 */
@@ -730,7 +753,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype));
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("cmpo 1,0\;addc %5,%4,%1\;addc %3,%2,%0" \
: "=r" (sh), "=&r" (sl) \
- : "%dI" (ah), "dI" (bh), "%dI" (al), "dI" (bl))
+ : "dI" (ah), "dI" (bh), "%dI" (al), "dI" (bl))
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("cmpo 0,0\;subc %5,%4,%1\;subc %3,%2,%0" \
: "=r" (sh), "=&r" (sl) \
@@ -781,7 +804,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype));
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("add%.l %5,%1\n\taddx%.l %3,%0" \
: "=d" ((USItype)(sh)), "=&d" ((USItype)(sl)) \
- : "%0" ((USItype)(ah)), "d" ((USItype)(bh)), \
+ : "0" ((USItype)(ah)), "d" ((USItype)(bh)), \
"%1" ((USItype)(al)), "g" ((USItype)(bl)))
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("sub%.l %5,%1\n\tsubx%.l %3,%0" \
@@ -840,12 +863,15 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype));
#define UMUL_TIME 100
#define UDIV_TIME 400
#endif /* not mc68020 */
-/* The '020, '030, '040 and '060 have bitfield insns. */
-#if defined (__mc68020__) || defined (mc68020) \
+/* The '020, '030, '040 and '060 have bitfield insns.
+ GCC 3.4 defines __mc68020__ when in CPU32 mode, check for __mcpu32__ to
+ exclude bfffo on that chip (bitfield insns not available). */
+#if (defined (__mc68020__) || defined (mc68020) \
|| defined (__mc68030__) || defined (mc68030) \
|| defined (__mc68040__) || defined (mc68040) \
|| defined (__mc68060__) || defined (mc68060) \
- || defined (__NeXT__)
+ || defined (__NeXT__)) \
+ && ! defined (__mcpu32__)
#define count_leading_zeros(count, x) \
__asm__ ("bfffo %1{%b2:%b2},%0" \
: "=d" ((USItype) (count)) \
@@ -858,7 +884,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype));
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("addu.co %1,%r4,%r5\n\taddu.ci %0,%r2,%r3" \
: "=r" (sh), "=&r" (sl) \
- : "%rJ" (ah), "rJ" (bh), "%rJ" (al), "rJ" (bl))
+ : "rJ" (ah), "rJ" (bh), "%rJ" (al), "rJ" (bl))
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("subu.co %1,%r4,%r5\n\tsubu.ci %0,%r2,%r3" \
: "=r" (sh), "=&r" (sl) \
@@ -955,15 +981,15 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype));
#endif /* __ns32000__ */
/* FIXME: We should test _IBMR2 here when we add assembly support for the
- system vendor compilers.
- FIXME: What's needed for gcc PowerPC VxWorks? __vxworks__ is not good
- enough, since that hits ARM and m68k too. */
+ system vendor compilers. */
#if (defined (_ARCH_PPC) /* AIX */ \
|| defined (_ARCH_PWR) /* AIX */ \
|| defined (__powerpc__) /* gcc */ \
|| defined (__POWERPC__) /* BEOS */ \
|| defined (__ppc__) /* Darwin */ \
- || defined (PPC) /* GNU/Linux, SysV */ \
+ || (defined (PPC) && ! defined (CPU_FAMILY)) /* gcc 2.7.x GNU&SysV */ \
+ || (defined (PPC) && defined (CPU_FAMILY) /* VxWorks */ \
+ && CPU_FAMILY == PPC) \
) && W_TYPE_SIZE == 32
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
do { \
@@ -976,7 +1002,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype));
else \
__asm__ ("{a%I5|add%I5c} %1,%4,%5\n\t{ae|adde} %0,%2,%3" \
: "=r" (sh), "=&r" (sl) \
- : "%r" (ah), "r" (bh), "%r" (al), "rI" (bl)); \
+ : "r" (ah), "r" (bh), "%r" (al), "rI" (bl)); \
} while (0)
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
do { \
@@ -1001,7 +1027,10 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype));
__asm__ ("{cntlz|cntlzw} %0,%1" : "=r" (count) : "r" (x))
#define COUNT_LEADING_ZEROS_0 32
#if defined (_ARCH_PPC) || defined (__powerpc__) || defined (__POWERPC__) \
- || defined (__ppc__) || defined (PPC) || defined (__vxworks__)
+ || defined (__ppc__) \
+ || (defined (PPC) && ! defined (CPU_FAMILY)) /* gcc 2.7.x GNU&SysV */ \
+ || (defined (PPC) && defined (CPU_FAMILY) /* VxWorks */ \
+ && CPU_FAMILY == PPC)
#define umul_ppmm(ph, pl, m0, m1) \
do { \
USItype __m0 = (m0), __m1 = (m1); \
@@ -1042,7 +1071,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype));
else \
__asm__ ("{a%I5|add%I5c} %1,%4,%5\n\t{ae|adde} %0,%2,%3" \
: "=r" (sh), "=&r" (sl) \
- : "%r" (ah), "r" (bh), "%r" (al), "rI" (bl)); \
+ : "r" (ah), "r" (bh), "%r" (al), "rI" (bl)); \
} while (0)
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
do { \
@@ -1087,7 +1116,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype));
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("addw %5,%1\n\taddwc %3,%0" \
: "=r" ((USItype)(sh)), "=&r" ((USItype)(sl)) \
- : "%0" ((USItype)(ah)), "g" ((USItype)(bh)), \
+ : "0" ((USItype)(ah)), "g" ((USItype)(bh)), \
"%1" ((USItype)(al)), "g" ((USItype)(bl)))
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("subw %5,%1\n\tsubwb %3,%0" \
@@ -1109,7 +1138,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype));
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("a %1,%5\n\tae %0,%3" \
: "=r" ((USItype)(sh)), "=&r" ((USItype)(sl)) \
- : "%0" ((USItype)(ah)), "r" ((USItype)(bh)), \
+ : "0" ((USItype)(ah)), "r" ((USItype)(bh)), \
"%1" ((USItype)(al)), "r" ((USItype)(bl)))
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("s %1,%5\n\tse %0,%3" \
@@ -1168,7 +1197,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype));
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("addcc %r4,%5,%1\n\taddx %r2,%3,%0" \
: "=r" (sh), "=&r" (sl) \
- : "%rJ" (ah), "rI" (bh),"%rJ" (al), "rI" (bl) \
+ : "rJ" (ah), "rI" (bh),"%rJ" (al), "rI" (bl) \
__CLOBBER_CC)
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("subcc %r4,%5,%1\n\tsubx %r2,%3,%0" \
@@ -1353,7 +1382,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype));
" addccc %r6,%7,%%g0\n" \
" addc %r2,%3,%0" \
: "=r" (sh), "=&r" (sl) \
- : "%rJ" (ah), "rI" (bh), "%rJ" (al), "rI" (bl), \
+ : "rJ" (ah), "rI" (bh), "%rJ" (al), "rI" (bl), \
"%rJ" ((al) >> 32), "rI" ((bl) >> 32) \
__CLOBBER_CC)
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
@@ -1371,7 +1400,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype));
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("addl2 %5,%1\n\tadwc %3,%0" \
: "=g" ((USItype)(sh)), "=&g" ((USItype)(sl)) \
- : "%0" ((USItype)(ah)), "g" ((USItype)(bh)), \
+ : "0" ((USItype)(ah)), "g" ((USItype)(bh)), \
"%1" ((USItype)(al)), "g" ((USItype)(bl)))
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("subl2 %5,%1\n\tsbwc %3,%0" \
@@ -1413,7 +1442,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype));
#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
__asm__ ("add %H1,%H5\n\tadc %H0,%H3" \
: "=r" ((unsigned int)(sh)), "=&r" ((unsigned int)(sl)) \
- : "%0" ((unsigned int)(ah)), "r" ((unsigned int)(bh)), \
+ : "0" ((unsigned int)(ah)), "r" ((unsigned int)(bh)), \
"%1" ((unsigned int)(al)), "rQR" ((unsigned int)(bl)))
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
__asm__ ("sub %H1,%H5\n\tsbc %H0,%H3" \
diff --git a/mpfr-test.h b/mpfr-test.h
index 0e021b87d..1b592bf44 100644
--- a/mpfr-test.h
+++ b/mpfr-test.h
@@ -22,6 +22,7 @@ MA 02111-1307, USA. */
#ifndef __MPFR_TEST_H__
#define __MPFR_TEST_H__
+#include <stdio.h>
#include "mpfr-impl.h"
/* generates a random long int, a random double,
@@ -65,7 +66,7 @@ void tests_machine_prec_double _MPFR_PROTO ((void));
void tests_machine_prec_long_double _MPFR_PROTO ((void));
unsigned short x86_fstcw _MPFR_PROTO ((void));
-void x86_fldcw _MPFR_PROTO ((unsigned short cw));
+void x86_fldcw _MPFR_PROTO ((unsigned short));
int mpfr_set_machine_rnd_mode _MPFR_PROTO ((mp_rnd_t));
void mpfr_test_init _MPFR_PROTO ((void));
@@ -78,8 +79,11 @@ int Isnan _MPFR_PROTO ((double));
void d_trace _MPFR_PROTO ((const char *, double));
void ld_trace _MPFR_PROTO ((const char *, long double));
-int mpfr_cmp_str _MPFR_PROTO ((mpfr_srcptr x, const char *s, int base,
- mp_rnd_t rnd));
+FILE *src_fopen _MPFR_PROTO ((const char *, const char *));
+void set_emin _MPFR_PROTO ((mp_exp_t));
+void set_emax _MPFR_PROTO ((mp_exp_t));
+
+int mpfr_cmp_str _MPFR_PROTO ((mpfr_srcptr x, const char *, int, mp_rnd_t));
#define mpfr_cmp_str1(x,s) mpfr_cmp_str(x,s,10,GMP_RNDN)
#define mpfr_set_str1(x,s) mpfr_set_str(x,s,10,GMP_RNDN)
diff --git a/mpfr.h b/mpfr.h
index e0b9a57b3..b444d0a75 100644
--- a/mpfr.h
+++ b/mpfr.h
@@ -25,7 +25,7 @@ MA 02111-1307, USA. */
/* Define MPFR version number */
#define MPFR_VERSION_MAJOR 2
#define MPFR_VERSION_MINOR 1
-#define MPFR_VERSION_PATCHLEVEL 0
+#define MPFR_VERSION_PATCHLEVEL 1
/* Macros dealing with MPFR VERSION */
#define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
@@ -435,7 +435,7 @@ int mpfr_cmp_f _MPFR_PROTO ((mpfr_srcptr, mpf_srcptr));
int mpfr_fma _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_srcptr,
mpfr_rnd_t));
-int mpfr_sum _MPFR_PROTO ((mpfr_ptr, mpfr_ptr __gmp_const tab[], unsigned long,
+int mpfr_sum _MPFR_PROTO ((mpfr_ptr, mpfr_ptr __gmp_const [], unsigned long,
mpfr_rnd_t));
void mpfr_init_cache _MPFR_PROTO ((mpfr_cache_t,int(*)(mpfr_ptr,mpfr_rnd_t)));
@@ -444,7 +444,7 @@ int mpfr_cache _MPFR_PROTO ((mpfr_ptr, mpfr_cache_t, mpfr_rnd_t));
void mpfr_free_cache _MPFR_PROTO ((void));
int mpfr_strtofr _MPFR_PROTO ((mpfr_ptr, __gmp_const char *, char **,
- unsigned int, mpfr_rnd_t));
+ int, mpfr_rnd_t));
#if defined (__cplusplus)
}
diff --git a/mpfr.texi b/mpfr.texi
index e19184ba3..0332da1b8 100644
--- a/mpfr.texi
+++ b/mpfr.texi
@@ -2,8 +2,8 @@
@c %**start of header
@setfilename mpfr.info
@documentencoding ISO-8859-1
-@set VERSION 2.1.0
-@set UPDATED-MONTH August 2004
+@set VERSION 2.1.1
+@set UPDATED-MONTH February 2005
@settitle MPFR @value{VERSION}
@synindex tp fn
@iftex
@@ -16,7 +16,7 @@ This manual documents how to install and use the Multiple Precision
Floating-Point Reliable Library, version @value{VERSION}.
Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-2003, 2004 Free Software Foundation, Inc.
+2003, 2004, 2005 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document under
the terms of the GNU Free Documentation License, Version 1.1 or any later
@@ -96,7 +96,7 @@ How to install and use MPFR, a library for reliable multiple precision floating-
@end ifnothtml
@menu
-* Copying:: GMP Copying Conditions (LGPL).
+* Copying:: MPFR Copying Conditions (LGPL).
* Introduction to MPFR:: Brief introduction to MPFR.
* Installing MPFR:: How to configure and compile the MPFR library.
* Reporting Bugs:: How to usefully report bugs.
@@ -446,7 +446,7 @@ of a floating-point number;
the corresponding C data type is @code{mp_prec_t}.
The precision can be any integer between @code{MPFR_PREC_MIN} and
@code{MPFR_PREC_MAX}. In the current implementation, @code{MPFR_PREC_MIN}
-is equal to 2 and @code{MPFR_PREC_MAX} is equal to @code{ULONG_MAX}/2.
+is equal to 2.
@cindex Rounding Modes
@tindex @code{mp_rnd_t}
@@ -593,6 +593,7 @@ precision, then MPFR will still compute the result with full precision.
* Comparison Functions::
* Special Functions::
* Input and Output Functions::
+* Integer Related Functions::
* Miscellaneous Functions::
* Rounding Modes::
* Exceptions::
@@ -649,7 +650,7 @@ The precision can be any integer between @code{MPFR_PREC_MIN} and
@end deftypefun
@deftypefun mp_prec_t mpfr_get_default_prec (void)
-Returns the default MPFR precision in bits.
+Return the default MPFR precision in bits.
@end deftypefun
@need 2000
@@ -699,7 +700,7 @@ number of bits used to store its mantissa.
These functions assign new values to already initialized floats
(@pxref{Initialization Functions}). When using any functions using
@code{intmax_t}, you must include @code{<stdint.h>} or @code{<inttypes.h>}
-before @file{mpfr.h}, to allow @file{mpfr.h} to define prototypes for
+before @file{mpfr.h}, to allow @file{mpfr.h} to define prototypes for
these functions.
@deftypefun int mpfr_set (mpfr_t @var{rop}, mpfr_t @var{op}, mp_rnd_t @var{rnd})
@@ -715,10 +716,10 @@ these functions.
Set the value of @var{rop} from @var{op}, rounded
towards the given direction @var{rnd}.
Note that the input 0 is converted to +0 by @code{mpfr_set_ui},
-@code{mpfr_set_si}, @code{mpfr_set_sj}, @code{mpfr_set_uj},
+@code{mpfr_set_si}, @code{mpfr_set_sj}, @code{mpfr_set_uj},
@code{mpfr_set_z}, @code{mpfr_set_q} and
@code{mpfr_set_f}, regardless of the rounding mode.
-If the system doesn't support IEEE 754 standard, @code{mpfr_set_d} and
+If the system doesn't support the IEEE-754 standard, @code{mpfr_set_d} and
@code{mpfr_set_ld} might not preserve the signed zeros.
@end deftypefun
@@ -731,33 +732,24 @@ two to the power @var{e}}, rounded towards the given direction @var{rnd}.
Note that the input 0 is converted to +0.
@end deftypefun
-@deftypefun int mpfr_set_str (mpfr_t @var{x}, const char *@var{s}, int @var{base}, mp_rnd_t @var{rnd})
-Set @var{x} to the value of the whole string @var{s} in base @var{base}
-(between 2 and 36), rounded in direction @var{rnd}.
-See the documentation of @code{mpfr_inp_str} for a detailed description
-of the valid string formats.
-This function returns 0 if the entire string up to the final @code{\0} is a
-valid number in base @var{base}; otherwise it returns @minus{}1.
-@end deftypefun
-
-@deftypefun void mpfr_set_inf (mpfr_t @var{x}, int @var{sign})
-@deftypefunx void mpfr_set_nan (mpfr_t @var{x})
-Set the variable @var{x} to infinity or NaN (Not-a-Number) respectively.
-In @code{mpfr_set_inf}, @var{x} is set to plus infinity iff @var{sign} is
-nonnegative.
-@end deftypefun
-
-@deftypefun void mpfr_swap (mpfr_t @var{x}, mpfr_t @var{y})
-Swap the values @var{x} and @var{y} efficiently. Warning: the
-precisions are exchanged too; in case the precisions are different,
-@code{mpfr_swap} is thus not equivalent to three @code{mpfr_set} calls
-using a third auxiliary variable.
+@deftypefun int mpfr_set_str (mpfr_t @var{rop}, const char *@var{s}, int @var{base}, mp_rnd_t @var{rnd})
+Set @var{rop} to the value of the whole string @var{s} in base @var{base},
+rounded in the direction @var{rnd}.
+See the documentation of @code{mpfr_strtofr} for a detailed description
+of the valid string formats.
+@c Additionally, special values
+@c @code{@@NaN@@}, @code{@@Inf@@}, @code{+@@Inf@@} and @code{-@@Inf@@},
+@c all case insensitive, without leading whitespace and possibly followed by
+@c other characters, are accepted too (it may change).
+This function returns 0 if the entire string up to the final null character
+is a valid number in base @var{base}; otherwise it returns @minus{}1, and
+@var{rop} may have changed.
@end deftypefun
-@deftypefun int mpfr_strtofr (mpfr_t @var{rop}, const char *@var{nptr}, char **@var{endptr}, unsigned int @var{base}, mp_rnd_t @var{rnd})
+@deftypefun int mpfr_strtofr (mpfr_t @var{rop}, const char *@var{nptr}, char **@var{endptr}, int @var{base}, mp_rnd_t @var{rnd})
- Read a floating point number from a string @var{nptr} in base @var{base}
- (from 2 to 62), rounded in direction @var{rnd}. If successful the
+ Read a floating point number from a string @var{nptr} in base @var{base},
+ rounded in the direction @var{rnd}. If successful, the
result is stored in @var{rop} and @code{*@var{endptr}} points to the
character just after those parsed. If @var{str} doesn't start with a
valid number then @var{rop} is set to zero and the value of @var{nptr}
@@ -765,18 +757,18 @@ using a third auxiliary variable.
Parsing follows the standard C @code{strtod} function. This means optional
leading whitespace, an optional @code{+} or @code{-}, mantissa digits, and an
- optional exponent consisting of an @code{e} or @code{E} (if
- @code{@var{base} <= 10}) or @code{@@}, an optional sign, and digits.
+ optional exponent consisting of an @code{e} or @code{E} (if
+ @math{@var{base} @le{} 10}) or @code{@@}, an optional sign, and digits.
A hex mantissa can be
- given with a leading @code{0x} or @code{0}', in which case @code{p} or
+ given with a leading @code{0x} or @code{0X}, in which case @code{p} or
@code{P} may introduce an optional binary exponent. A binary
mantissa can be given with a leading @code{0b} or @code{0B}, in which case
- @code{e}, @code{E}, @code{p}, @code{P} or @code{@@} may introduce the
+ @code{e}, @code{E}, @code{p}, @code{P} or @code{@@} may introduce the
binary exponent.
- In addition @code{infinity}, @code{inf} (if @code{@var{base} <= 10} )
+ In addition @code{infinity}, @code{inf} (if @math{@var{base} @le{} 10})
or @code{@@inf@@} with an optional sign, or @code{nan},
- @code{nan(n-char-sequence)} (if @code{@var{base} <= 10} ), @code{@@nan@@}
+ @code{nan(n-char-sequence)} (if @math{@var{base} @le{} 10}), @code{@@nan@@}
or @code{@@nan@@(n-char-sequence)} all non case significant, can be given.
A @code{n-char-sequence} is a string containing only digits (0, 1, 2, ..., 9)
and non-digits (_, a, b, ..., z, A, B, ..., Z).
@@ -785,7 +777,7 @@ using a third auxiliary variable.
be valid. If an exponent has no digits it's ignored and parsing
stops after the mantissa. If an @code{0x}, @code{0X}, @code{0b} or
@code{0B} is not followed by hexadecimal/binary digits, parsing stops
- after the first @code{0}:
+ after the first @code{0}:
the subject sequence is defined as the longest initial
subsequence of the input string, starting with the first
non-white-space character, that is of the expected form.
@@ -796,41 +788,57 @@ using a third auxiliary variable.
whereas @code{@@} represents a power of the base (i.e. 16).
If the argument @var{base} is different from 0, it must be in the range 2
- to 62. For bases up to 36,
- case is ignored; upper-case and lower-case letters have the same
- value; for bases 37 to 62, upper-case letter represent the usual
- 10..35, while lower-case letter represent 36..61.
-
- If @code{base} is 0, then it tries to indentify the used base: if the
- mantissa begins with the '0x' prefix, it assumes that @var{base} is 16.
- If it begins with '0b', it assumes that @var{base} is 2. Otherwise, it
+ to 36.
+@c For bases up to 36,
+ Case is ignored; upper-case and lower-case letters have the same
+ value
+@c ; for bases 37 to 62, upper-case letter represent the usual
+@c 10..35, while lower-case letter represent 36..61.
+
+ If @code{base} is 0, then it tries to identify the used base: if the
+ mantissa begins with the @code{0x} prefix, it assumes that @var{base} is 16.
+ If it begins with @code{0b}, it assumes that @var{base} is 2. Otherwise, it
assumes it is 10.
- It returns an usual ternary value.
- If @var{endptr} is not @code{NULL}, a pointer to the character after the last
- character used in the conversion is stored in the location
+ It returns a usual ternary value.
+ If @var{endptr} is not a null pointer, a pointer to the character after
+ the last character used in the conversion is stored in the location
referenced by @var{endptr}.
@end deftypefun
+@deftypefun void mpfr_set_inf (mpfr_t @var{x}, int @var{sign})
+@deftypefunx void mpfr_set_nan (mpfr_t @var{x})
+Set the variable @var{x} to infinity or NaN (Not-a-Number) respectively.
+In @code{mpfr_set_inf}, @var{x} is set to plus infinity iff @var{sign} is
+nonnegative.
+@end deftypefun
+
+@deftypefun void mpfr_swap (mpfr_t @var{x}, mpfr_t @var{y})
+Swap the values @var{x} and @var{y} efficiently. Warning: the
+precisions are exchanged too; in case the precisions are different,
+@code{mpfr_swap} is thus not equivalent to three @code{mpfr_set} calls
+using a third auxiliary variable.
+@end deftypefun
+
@node Combined Initialization and Assignment Functions, Conversion Functions, Assignment Functions, MPFR Interface
@comment node-name, next, previous, up
@cindex Combined initialization and assignment functions
@section Combined Initialization and Assignment Functions
-@deftypefun int mpfr_init_set (mpfr_t @var{rop}, mpfr_t @var{op}, mp_rnd_t @var{rnd})
-@deftypefunx int mpfr_init_set_ui (mpfr_t @var{rop}, unsigned long int @var{op}, mp_rnd_t @var{rnd})
-@deftypefunx int mpfr_init_set_si (mpfr_t @var{rop}, signed long int @var{op}, mp_rnd_t @var{rnd})
-@deftypefunx int mpfr_init_set_d (mpfr_t @var{rop}, double @var{op}, mp_rnd_t @var{rnd})
-@deftypefunx int mpfr_init_set_ld (mpfr_t @var{rop}, long double @var{op}, mp_rnd_t @var{rnd})
-@deftypefunx int mpfr_init_set_z (mpfr_t @var{rop}, mpz_t @var{op}, mp_rnd_t @var{rnd})
-@deftypefunx int mpfr_init_set_q (mpfr_t @var{rop}, mpq_t @var{op}, mp_rnd_t @var{rnd})
-@deftypefunx int mpfr_init_set_f (mpfr_t @var{rop}, mpf_t @var{op}, mp_rnd_t @var{rnd})
+@deftypefn Macro int mpfr_init_set (mpfr_t @var{rop}, mpfr_t @var{op}, mp_rnd_t @var{rnd})
+@deftypefnx Macro int mpfr_init_set_ui (mpfr_t @var{rop}, unsigned long int @var{op}, mp_rnd_t @var{rnd})
+@deftypefnx Macro int mpfr_init_set_si (mpfr_t @var{rop}, signed long int @var{op}, mp_rnd_t @var{rnd})
+@deftypefnx Macro int mpfr_init_set_d (mpfr_t @var{rop}, double @var{op}, mp_rnd_t @var{rnd})
+@deftypefnx Macro int mpfr_init_set_ld (mpfr_t @var{rop}, long double @var{op}, mp_rnd_t @var{rnd})
+@deftypefnx Macro int mpfr_init_set_z (mpfr_t @var{rop}, mpz_t @var{op}, mp_rnd_t @var{rnd})
+@deftypefnx Macro int mpfr_init_set_q (mpfr_t @var{rop}, mpq_t @var{op}, mp_rnd_t @var{rnd})
+@deftypefnx Macro int mpfr_init_set_f (mpfr_t @var{rop}, mpf_t @var{op}, mp_rnd_t @var{rnd})
Initialize @var{rop} and set its value from @var{op}, rounded in the direction
@var{rnd}.
The precision of @var{rop} will be taken from the active default precision,
as set by @code{mpfr_set_default_prec}.
-@end deftypefun
+@end deftypefn
@deftypefun int mpfr_init_set_str (mpfr_t @var{x}, const char *@var{s}, int @var{base}, mp_rnd_t @var{rnd})
Initialize @var{x} and set its value from
@@ -852,12 +860,6 @@ If the system doesn't support IEEE 754 standard, this function
might not preserve the signed zeros.
@end deftypefun
-@deftypefun double mpfr_get_d1 (mpfr_t @var{op})
-Convert @var{op} to a @code{double}, using the default MPFR rounding mode
-(see function @code{mpfr_set_default_rounding_mode}). This function is
-obsolete.
-@end deftypefun
-
@deftypefun double mpfr_get_d_2exp (long *@var{exp}, mpfr_t @var{op}, mp_rnd_t @var{rnd})
Return @var{d} and set @var{exp} such that @math{0.5@le{}@GMPabs{@var{d}}<1}
and @m{@var{d}\times 2^{exp}, @var{d} times 2 raised to @var{exp}} equals
@@ -868,7 +870,7 @@ and @m{@var{d}\times 2^{exp}, @var{d} times 2 raised to @var{exp}} equals
@deftypefunx {unsigned long} mpfr_get_ui (mpfr_t @var{op}, mp_rnd_t @var{rnd})
@deftypefunx intmax_t mpfr_get_sj (mpfr_t @var{op}, mp_rnd_t @var{rnd})
@deftypefunx uintmax_t mpfr_get_uj (mpfr_t @var{op}, mp_rnd_t @var{rnd})
-Convert @var{op} to a @code{long}, an @code{unsigned long},
+Convert @var{op} to a @code{long}, an @code{unsigned long},
an @code{intmax_t} or an @code{uintmax_t} (respectively) after rounding
it with respect to @var{rnd}.
If @var{op} is NaN, the result is undefined.
@@ -895,13 +897,13 @@ behavior is undefined.
@end deftypefun
@deftypefun void mpfr_get_z (mpz_t @var{rop}, mpfr_t @var{op}, mp_rnd_t @var{rnd})
-Convert @var{op} to a @code{mpz_t}, after rounding it with respect to
+Convert @var{op} to a @code{mpz_t}, after rounding it with respect to
@var{rnd}. If @var{op} is NaN or Inf, the result is undefined.
@end deftypefun
@deftypefun {char *} mpfr_get_str (char *@var{str}, mp_exp_t *@var{expptr}, int @var{base}, size_t @var{n}, mpfr_t @var{op}, mp_rnd_t @var{rnd})
Convert @var{op} to a string of digits in base @var{base}, with rounding in
-direction @var{rnd}. The base may vary from 2 to 36.
+the direction @var{rnd}. The base may vary from 2 to 36.
The generated string is a fraction, with an implicit radix point immediately
to the left of the first digit. For example, the number -3.1416 would be
@@ -921,7 +923,7 @@ the current allocation function, and a pointer to the string is returned.
To free the returned string, you must use @code{mpfr_free_str}.
If @var{str} is not a null pointer, it should point to a block of storage
-large enough for the mantissa, i.e., at least @code{max(@var{n} + 2, 7)}.
+large enough for the mantissa, i.e., at least @code{max(@var{n} + 2, 7)}.
The extra two bytes are for a possible minus sign, and for the terminating null
character.
@@ -939,10 +941,15 @@ case a null pointer is returned.
@deftypefun void mpfr_free_str (char *@var{str})
Free a string allocated by @code{mpfr_get_str} using the current unallocation
-function (preliminary interface).
+function (preliminary interface).
The block is assumed to be @code{strlen(@var{str})+1} bytes.
For more information about how it is done:
+@ifnothtml
@pxref{Custom Allocation,,, gmp,GNU MP}.
+@end ifnothtml
+@ifhtml
+see Custom Allocation (GNU MP).
+@end ifhtml
@end deftypefun
@deftypefun int mpfr_fits_ulong_p (mpfr_t @var{op}, mp_rnd_t @var{rnd})
@@ -1063,22 +1070,18 @@ Just changes the sign if @var{rop} and @var{op} are the same variable.
@deftypefun int mpfr_mul_2ui (mpfr_t @var{rop}, mpfr_t @var{op1}, unsigned long int @var{op2}, mp_rnd_t @var{rnd})
@deftypefunx int mpfr_mul_2si (mpfr_t @var{rop}, mpfr_t @var{op1}, long int @var{op2}, mp_rnd_t @var{rnd})
-@deftypefunx int mpfr_mul_2exp (mpfr_t @var{rop}, mpfr_t @var{op1}, unsigned long int @var{op2}, mp_rnd_t @var{rnd})
Set @var{rop} to @m{@var{op1} \times 2^{op2}, @var{op1} times 2 raised
to @var{op2}}
rounded in the direction @var{rnd}. Just increases the exponent by @var{op2}
when @var{rop} and @var{op1} are identical.
-[@code{mpfr_mul_2exp} is kept for upward compatibility.]
@end deftypefun
@deftypefun int mpfr_div_2ui (mpfr_t @var{rop}, mpfr_t @var{op1}, unsigned long int @var{op2}, mp_rnd_t @var{rnd})
@deftypefunx int mpfr_div_2si (mpfr_t @var{rop}, mpfr_t @var{op1}, long int @var{op2}, mp_rnd_t @var{rnd})
-@deftypefunx int mpfr_div_2exp (mpfr_t @var{rop}, mpfr_t @var{op1}, unsigned long int @var{op2}, mp_rnd_t @var{rnd})
Set @var{rop} to @m{@var{op1}/2^{op2}, @var{op1} divided by 2 raised
to @var{op2}}
rounded in the direction @var{rnd}. Just decreases the exponent by @var{op2}
when @var{rop} and @var{op1} are identical.
-[@code{mpfr_div_2exp} is kept for upward compatibility.]
@end deftypefun
@node Comparison Functions, Special Functions, Basic Arithmetic Functions, MPFR Interface
@@ -1100,7 +1103,7 @@ Compare @var{op1} and @var{op2}. Return a positive value if @math{@var{op1} >
@math{@var{op1} < @var{op2}}.
Both @var{op1} and @var{op2} are considered to their full own precision,
which may differ.
-If one of the operands is NaN (Not-a-Number), it returns 0 and set
+If one of the operands is NaN (Not-a-Number), return zero and set
the erange flag.
@end deftypefun
@@ -1114,7 +1117,7 @@ the power @var{e}}. Similar as above.
Compare @math{|@var{op1}|} and @math{|@var{op2}|}. Return a positive value if
@math{|@var{op1}| > |@var{op2}|}, zero if @math{|@var{op1}| = |@var{op2}|}, and
a negative value if @math{|@var{op1}| < |@var{op2}|}.
-If one of the operands is NaN (Not-a-Number), it returns 0 and set
+If one of the operands is NaN (Not-a-Number), return zero and set
the erange flag.
@end deftypefun
@@ -1172,7 +1175,7 @@ compared), zero otherwise.
@cindex Special functions
All those functions, except explicitly stated, return zero for an
-exact return value, a positive value for a return value larger than the
+exact return value, a positive value for a return value larger than the
exact result, and a negative value otherwise.
@deftypefun int mpfr_log (mpfr_t @var{rop}, mpfr_t @var{op}, mp_rnd_t @var{rnd})
@@ -1280,22 +1283,24 @@ If any operand is negative, the return value is NaN.
Set @var{rop} to the logarithm of 2, the value of @m{\pi,Pi}, the value
of Euler's constant 0.577@dots{}, respectively, rounded in the direction
@var{rnd}. These functions cache the computed values to avoid other
-calculations if a lower or equal precision is requested. To free theses caches,
+calculations if a lower or equal precision is requested. To free these caches,
use @code{mpfr_free_cache}.
@end deftypefun
@deftypefun void mpfr_free_cache (void)
Free the cache used by the functions computing constants if needed
-(currently
+(currently
@code{mpfr_const_log2}, @code{mpfr_const_pi} and
@code{mpfr_const_euler}).
@end deftypefun
@deftypefun int mpfr_sum (mpfr_t @var{rop}, const mpfr_t* const @var{tab}[], unsigned long @var{n}, mp_rnd_t @var{rnd})
-Set @var{ret} to the sum of all elements of @var{tab} whose size is @var{n}, rounded in the direction @var{rnd}. Warning, @var{tab} is a table of pointer to mpfr_t, not a table of mpfr_t (priliminary interface).
+Set @var{ret} to the sum of all elements of @var{tab} whose size is @var{n},
+rounded in the direction @var{rnd}. Warning, @var{tab} is a table of pointers
+to mpfr_t, not a table of mpfr_t (preliminary interface).
@end deftypefun
-@node Input and Output Functions, Miscellaneous Functions, Special Functions, MPFR Interface
+@node Input and Output Functions, Integer Related Functions, Special Functions, MPFR Interface
@comment node-name, next, previous, up
@section Input and Output Functions
@cindex Float input and output functions
@@ -1315,7 +1320,7 @@ prototypes for these functions.
@deftypefun size_t mpfr_out_str (FILE *@var{stream}, int @var{base}, size_t @var{n}, mpfr_t @var{op}, mp_rnd_t @var{rnd})
Output @var{op} on stream @var{stream}, as a string of digits in
-base @var{base}, rounded in direction @var{rnd}.
+base @var{base}, rounded in the direction @var{rnd}.
The base may vary from 2 to 36. Print @var{n} significant digits exactly,
or if @var{n} is 0, the maximum number of digits accurately representable
by @var{op} (this feature may disappear).
@@ -1330,21 +1335,26 @@ Return the number of bytes written, or if an error occurred, return 0.
@deftypefun size_t mpfr_inp_str (mpfr_t @var{rop}, FILE *@var{stream}, int @var{base}, mp_rnd_t @var{rnd})
Input a string in base @var{base} from stream @var{stream},
-rounded in direction @var{rnd}, and put the
-read float in @var{rop}. The string is of the form @samp{M@@N} or, if the
-base is 10 or less, alternatively @samp{MeN} or @samp{MEN}, or, if the base
-is 16, alternatively @samp{MpB} or @samp{MPB}.
-@samp{M} is the mantissa in the specified base, @samp{N} is the exponent
-written in decimal for the specified base, and in base 16, @samp{B} is the
-binary exponent written in decimal (i.e.@: it indicates the power of 2 by
-which the mantissa is to be scaled).
-The argument @var{base} may be in the range 2 to 36.
-
-Special values can be read as follows (the case does not matter):
-@code{@@NaN@@}, @code{@@Inf@@}, @code{+@@Inf@@} and @code{-@@Inf@@},
-possibly followed by other characters; if the base is smaller or equal
-to 16, the following strings are accepted too: @code{NaN}, @code{Inf},
-@code{+Inf} and @code{-Inf}.
+rounded in the direction @var{rnd}, and put the
+read float in @var{rop}.
+@c The argument @var{base} must be in the range 2 to 36.
+
+@c The string is of the form @samp{M@@N} or, if the
+@c base is 10 or less, alternatively @samp{MeN} or @samp{MEN}, or, if the base
+@c is 16, alternatively @samp{MpB} or @samp{MPB}.
+@c @samp{M} is the mantissa in the specified base, @samp{N} is the exponent
+@c written in decimal for the specified base, and in base 16, @samp{B} is the
+@c binary exponent written in decimal (i.e.@: it indicates the power of 2 by
+@c which the mantissa is to be scaled).
+This function reads a word (defined as a sequence of characters between
+whitespace) and parses it using @code{mpfr_set_str} (it may change).
+See the documentation of @code{mpfr_strtofr} for a detailed description
+of the valid string formats.
+@c Special values can be read as follows (the case does not matter):
+@c @code{@@NaN@@}, @code{@@Inf@@}, @code{+@@Inf@@} and @code{-@@Inf@@},
+@c possibly followed by other characters; if the base is smaller or equal
+@c to 16, the following strings are accepted too: @code{NaN}, @code{Inf},
+@c @code{+Inf} and @code{-Inf}.
Return the number of bytes read, or if an error occurred, return 0.
@end deftypefun
@@ -1354,10 +1364,10 @@ Return the number of bytes read, or if an error occurred, return 0.
@c @code{mpfr_out_raw}, and put the result in @var{float}.
@c @end deftypefun
-@node Miscellaneous Functions, Rounding Modes, Input and Output Functions, MPFR Interface
+@node Integer Related Functions, Miscellaneous Functions, Input and Output Functions, MPFR Interface
@comment node-name, next, previous, up
-@section Miscellaneous Functions
-@cindex Miscellaneous float functions
+@section Integer Related Functions
+@cindex Integer Related Functions
@deftypefun int mpfr_rint (mpfr_t @var{rop}, mpfr_t @var{op}, mp_rnd_t @var{rnd})
@deftypefunx int mpfr_ceil (mpfr_t @var{rop}, mpfr_t @var{op})
@@ -1413,6 +1423,11 @@ the fractional part is generated).
Return non-zero iff @var{op} is an integer.
@end deftypefun
+@node Miscellaneous Functions, Rounding Modes, Integer Related Functions, MPFR Interface
+@comment node-name, next, previous, up
+@section Miscellaneous Functions
+@cindex Miscellaneous float functions
+
@deftypefun void mpfr_nexttoward (mpfr_t @var{x}, mpfr_t @var{y})
If @var{x} or @var{y} is NaN, set @var{x} to NaN. Otherwise, if @var{x}
is different from @var{y}, replace @var{x} by the next floating-point
@@ -1492,7 +1507,7 @@ Return the MPFR version, as a null-terminated string.
@defmacx MPFR_VERSION_MINOR
@defmacx MPFR_VERSION_PATCHLEVEL
@code{MPFR_VERSION} is the version of MPFR as a preprocessing constant.
-@code{MPFR_VERSION_MAJOR}, @code{MPFR_VERSION_MINOR} and
+@code{MPFR_VERSION_MAJOR}, @code{MPFR_VERSION_MINOR} and
@code{MPFR_VERSION_PATCHLEVEL} are respectively the major, minor and patch
level of MPFR version, as preprocessing constants.
@end defmac
@@ -1500,7 +1515,7 @@ level of MPFR version, as preprocessing constants.
@deftypefn Macro long MPFR_VERSION_NUM (@var{major}, @var{minor}, @var{patchlevel})
Create an integer in the same format as used by @code{MPFR_VERSION} from the
given @var{major}, @var{minor} and @var{patchlevel}.
-Here is an example of how to check the MPFR version at compiled time:
+Here is an example of how to check the MPFR version at compile time:
@example
#if (!defined(MPFR_VERSION) || (MPFR_VERSION<MPFR_VERSION_NUM(2,1,0)))
# error "Wrong MPFR version."
@@ -1513,16 +1528,16 @@ Here is an example of how to check the MPFR version at compiled time:
@cindex Rounding Modes
@deftypefun void mpfr_set_default_rounding_mode (mp_rnd_t @var{rnd})
-Sets the default rounding mode to @var{rnd}.
+Set the default rounding mode to @var{rnd}.
The default rounding mode is to nearest initially.
@end deftypefun
@deftypefun mp_rnd_t mpfr_get_default_rounding_mode (void)
-Gets the default rounding mode.
+Get the default rounding mode.
@end deftypefun
@deftypefun int mpfr_prec_round (mpfr_t @var{x}, mp_prec_t @var{prec}, mp_rnd_t @var{rnd})
-Rounds @var{x} according to @var{rnd} with precision @var{prec}, which
+Round @var{x} according to @var{rnd} with precision @var{prec}, which
must be an integer between @code{MPFR_PREC_MIN} and @code{MPFR_PREC_MAX}
(otherwise the behavior is undefined).
If @var{prec} is greater or equal to the precision of @var{x}, then new
@@ -1536,7 +1551,7 @@ direction. In both cases, the precision of @var{x} is changed to @var{prec}.
@end deftypefun
@deftypefun {const char *} mpfr_print_rnd_mode (mp_rnd_t @var{rnd})
-Returns the input string (GMP_RNDD, GMP_RNDU, GMP_RNDN, GMP_RNDZ)
+Return the input string (GMP_RNDD, GMP_RNDU, GMP_RNDN, GMP_RNDZ)
corresponding to the rounding mode @var{rnd} or a null pointer if
@var{rnd} is an invalid rounding mode.
@end deftypefun
@@ -1548,7 +1563,7 @@ corresponding to the rounding mode @var{rnd} or a null pointer if
@cindex Exceptions
Note: Overflow handling is still experimental and currently implemented
-very partially. If an overflow occurs internally at the wrong place,
+partially. If an overflow occurs internally at the wrong place,
anything can happen (crash, wrong results, etc).
@deftypefun mp_exp_t mpfr_get_emin (void)
@@ -1578,9 +1593,9 @@ behavior will be undefined, in the sense of the ISO C standard.
@deftypefunx mp_exp_t mpfr_get_emax_min (void)
@deftypefunx mp_exp_t mpfr_get_emax_max (void)
Return the minimum and maximum of the smallest and largest exponents
-allowed for @code{mpfr_set_emin} and @code{mpfr_set_emax}. Theses values
+allowed for @code{mpfr_set_emin} and @code{mpfr_set_emax}. These values
are implementation dependent; it is possible to create a non
-portable program by writting @code{mpfr_set_emax(mpfr_get_emax_max())}
+portable program by writing @code{mpfr_set_emax(mpfr_get_emax_max())}
and @code{mpfr_set_emin(mpfr_get_emin_min())} since the values
of the smallest and largest exponents become implementation dependent.
@end deftypefun
@@ -1617,7 +1632,7 @@ Clear all global flags (underflow, overflow, inexact, invalid, erange).
@deftypefunx int mpfr_nanflag_p (void)
@deftypefunx int mpfr_inexflag_p (void)
@deftypefunx int mpfr_erangeflag_p (void)
-Return the corresponding (underflow, overflow, invalid, inexact, erange)
+Return the corresponding (underflow, overflow, invalid, inexact, erange)
flag, which is non-zero iff the flag is set.
@end deftypefun
@@ -1635,7 +1650,8 @@ flag, which is non-zero iff the flag is set.
@section Advanced Functions
@cindex Advanced Functions
-All the given interface are preliminary. It might change incompatibly in future revisions.
+All the given interfaces are preliminary. They might change incompatibly in
+future revisions.
@defmac MPFR_DECL_INIT (@var{name}, @var{prec})
This macro declares @var{name} as an automatic variable of type @code{mpfr_t},
@@ -1645,42 +1661,42 @@ You must use this macro in the declaration section. This macro is much faster th
drawbacks:
@itemize @bullet
-@item You @strong{must not} call @code{mpfr_clear} with variables
+@item You @strong{must not} call @code{mpfr_clear} with variables
created with this macro (The storage is allocated at the point of declaration
and deallocated when the brace-level is exited.).
@item You @strong{can not} change their precision.
@item You @strong{should not} create variables with huge precision with this macro.
@item Your compiler must support @samp{Non-Constant Initializers} (standard
-in C++ and ISO C99) and @samp{Tokken Pasting}
+in C++ and ISO C99) and @samp{Token Pasting}
(standard in ISO C89). If @var{prec} is not a compiler constant, your compiler
must support @samp{Variable-length automatic arrays} (standard in ISO C99).
-@samp{GCC 2.95.3} supports all theses features.
+@samp{GCC 2.95.3} supports all these features.
@end itemize
@end defmac
@deftypefun void mpfr_inits (mpfr_t @var{x}, ...)
Initialize all the @code{mpfr_t} variables of the given @code{va_list},
-set their precision to be the default precision and their value to NaN.
+set their precision to be the default precision and their value to NaN.
See @code{mpfr_init} for more details.
The @code{va_list} is assumed to be composed only of type @code{mpfr_t}.
-It begins from @var{x}. It ends when it encounters a @code{NULL} pointer.
+It begins from @var{x}. It ends when it encounters a null pointer.
@end deftypefun
@deftypefun void mpfr_inits2 (mp_prec_t @var{prec}, mpfr_t @var{x}, ...)
Initialize all the @code{mpfr_t} variables of the given @code{va_list},
set their precision to be @strong{exactly}
-@var{prec} bits and their value to NaN.
+@var{prec} bits and their value to NaN.
See @code{mpfr_init2} for more details.
The @code{va_list} is assumed to be composed only of type @code{mpfr_t}.
-It begins from @var{x}. It ends when it encounters a @code{NULL} pointer.
+It begins from @var{x}. It ends when it encounters a null pointer.
@end deftypefun
@deftypefun void mpfr_clears (mpfr_t @var{x}, ...)
Free the space occupied by all the @code{mpfr_t} variables of the given
@code{va_list}. See @code{mpfr_clear} for more details.
The @code{va_list} is assumed to be composed only of type @code{mpfr_t}.
-It begins from @var{x}. It ends when it encounters a @code{NULL} pointer.
+It begins from @var{x}. It ends when it encounters a null pointer.
@end deftypefun
Here is an example of how to use multiple initialization functions:
@@ -1688,9 +1704,9 @@ Here is an example of how to use multiple initialization functions:
@example
@{
mpfr_t x, y, z, t;
- mpfr_inits2 (256, x, y, z, t, NULL);
+ mpfr_inits2 (256, x, y, z, t, (void *) 0);
@dots{}
- mpfr_clears (x, y, z, t, NULL);
+ mpfr_clears (x, y, z, t, (void *) 0);
@}
@end example
@@ -1741,6 +1757,13 @@ it just computes @math{|@var{op1}-@var{op2}|/@var{op1}}, using the
rounding mode @var{rnd} for all operations and the precision of @var{rop}.
@end deftypefun
+@deftypefun int mpfr_mul_2exp (mpfr_t @var{rop}, mpfr_t @var{op1}, unsigned long int @var{op2}, mp_rnd_t @var{rnd})
+@deftypefunx int mpfr_div_2exp (mpfr_t @var{rop}, mpfr_t @var{op1}, unsigned long int @var{op2}, mp_rnd_t @var{rnd})
+See @code{mpfr_mul_2ui} and @code{mpfr_div_2ui}. These functions are only kept
+for compatibility with MPF.
+@end deftypefun
+
+
@node Internals, , Compatibility with MPF, MPFR Interface
@section Internals
@cindex Internals
@@ -1758,7 +1781,7 @@ The @code{mpfr_t} type consists of four fields.
@item The @code{_mpfr_prec} field is used to store the precision of
the variable (in bits); this is not less than @code{MPFR_PREC_MIN}.
-@item The @code{_mpfr_sign} field is used to store the sign of the variable.
+@item The @code{_mpfr_sign} field is used to store the sign of the variable.
@item The @code{_mpfr_exp} field stores the exponent.
An exponent of 0 means a radix point just above the most significant
@@ -1769,7 +1792,7 @@ A NaN, an Infinity and a Zero are indicated by a special value of the exponent.
@item Finally, the @code{_mpfr_d} is a pointer to the limbs, least
significant limbs stored first.
The number of limbs in use is controlled by @code{_mpfr_prec}, namely
-ceil(@code{_mpfr_prec}/@code{BITS_PER_MP_LIMB}).
+ceil(@code{_mpfr_prec}/@code{mp_bits_per_limb}).
Non-singular values always have the most significant bit of the most
significant limb set to 1. When the precision does not correspond to a
whole number of limbs, the excess bits at the low end of the data are zero.
@@ -1793,14 +1816,21 @@ whole number of limbs, the excess bits at the low end of the data are zero.
@deftypefun int mpfr_can_round (mpfr_t @var{b}, mp_exp_t @var{err}, mp_rnd_t @var{rnd1}, mp_rnd_t @var{rnd2}, mp_prec_t @var{prec})
Assuming @var{b} is an approximation of an unknown number
-@var{x} in direction @var{rnd1} with error at most two to the power
-E(b)-@var{err} where E(b) is the exponent of @var{b}, returns a non-zero
+@var{x} in the direction @var{rnd1} with error at most two to the power
+E(b)-@var{err} where E(b) is the exponent of @var{b}, return a non-zero
value if one is able to round exactly @var{x} to precision
-@var{prec} with direction @var{rnd2},
+@var{prec} with the direction @var{rnd2},
and 0 otherwise (including for NaN and Inf).
This function @strong{does not modify} its arguments.
@end deftypefun
+@deftypefun double mpfr_get_d1 (mpfr_t @var{op})
+Convert @var{op} to a @code{double}, using the default MPFR rounding mode
+(see function @code{mpfr_set_default_rounding_mode}). This function is
+obsolete.
+@end deftypefun
+
+
@c @deftypefun void mpfr_set_str_binary (mpfr_t @var{x}, const char *@var{s})
@c Set @var{x} to the value of the binary number in string @var{s}, which has to
@c be of the
@@ -1823,15 +1853,16 @@ This function @strong{does not modify} its arguments.
@unnumbered Contributors
The main developers consist of Guillaume Hanrot, Vincent Lef@`evre,
-Kevin Ryde and Paul Zimmermann.
+Patrick P@'elissier and Paul Zimmermann.
We would like to thank Jean-Michel Muller and Joris van der Hoeven for very
fruitful discussions at the beginning of that project, Torbj@"orn Granlund
-and Kevin Ryde
-for their help about design issues
-and their suggestions for an easy integration into GNU MP,
+and Kevin Ryde for their help about design issues,
and Nathalie Revol for her careful reading of a previous version of
this documentation.
+Kevin Ryde did a tremendous job for the portability of MPFR,
+and integrating it into GMP 4.x;
+alas the GMP developers decided in January 2004 not to include MPFR any more.
Sylvie Boldo from ENS-Lyon, France,
contributed the functions @code{mpfr_agm} and @code{mpfr_log}.
@@ -1848,13 +1879,10 @@ contributed the original version of @file{mul_ui.c}, the @file{gmp_op.c}
file, and helped to the Windows porting.
Jean-Luc R@'emy contributed the @code{mpfr_zeta} code.
Ludovic Meunier helped in the design of the @code{mpfr_erf} code.
-Patrick P@'elissier has worked on low-precision optimizations
-(new internal format), on debugging (specially the file @file{gmp_op.c})
-and on some other functions (@code{MPFR_DECL_INIT}, @code{mpfr_set_sj}, etc.).
The development of the MPFR library would not have been possible without the
continuous support of LORIA, INRIA and INRIA Lorraine.
-The development of MPFR was also supported by a grant
+The development of MPFR was also supported by a grant
(202F0659 00 MPN 121) from the Conseil R@'egional de Lorraine in 2002.
@node References, GNU Free Documentation License, Contributors, Top
diff --git a/mpn_exp.c b/mpn_exp.c
index ddead85ea..a32ce23d9 100644
--- a/mpn_exp.c
+++ b/mpn_exp.c
@@ -123,7 +123,7 @@ mpfr_mpn_exp (mp_limb_t *a, mp_exp_t *exp_r, int b, mp_exp_t e, size_t n)
(mpn_scan1 (c + 2 * n1, 0) < (n - 2 * n1) * BITS_PER_MP_LIMB))
error = i;
- if (e & (1 << i))
+ if (e & ((mp_exp_t) 1 << i))
{
/* multiply A by B */
c[2 * n - 1] = mpn_mul_1 (c + n - 1, a, n, B);
diff --git a/mul.c b/mul.c
index 8c65d8655..a52493e26 100644
--- a/mul.c
+++ b/mul.c
@@ -22,7 +22,7 @@ MA 02111-1307, USA. */
#include "mpfr-impl.h"
int
-mpfr_mul (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
+mpfr_mul (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
{
int sign_product, cc, inexact;
mp_exp_t ax;
diff --git a/rint.c b/rint.c
index 029489aed..3bbf73bf9 100644
--- a/rint.c
+++ b/rint.c
@@ -1,6 +1,6 @@
/* mpfr_rint -- Round to an integer.
-Copyright 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -205,8 +205,6 @@ mpfr_rint (mpfr_ptr r, mpfr_srcptr u, mpfr_rnd_t rnd_mode)
uj = un - ui; /* lowest limb of the integer part in u */
rj = rn - ui; /* lowest limb of the integer part in r */
- MPN_ZERO(rp, rj);
-
if (rp != up)
MPN_COPY(rp + rj, up + uj, ui);
@@ -270,6 +268,8 @@ mpfr_rint (mpfr_ptr r, mpfr_srcptr u, mpfr_rnd_t rnd_mode)
(sh == 0 && (MPFR_ASSERTN (uj >= 1),
up[uj - 1] & MPFR_LIMB_HIGHBIT) != 0));
}
+
+ MPN_ZERO (rp-rj, rj);
}
if (sh != 0)
diff --git a/set.c b/set.c
index 8af4360f0..76b8789c8 100644
--- a/set.c
+++ b/set.c
@@ -1,6 +1,6 @@
/* mpfr_set -- copy of a floating-point number
-Copyright 1999, 2001, 2002, 2003, 2004 Free Software Foundation.
+Copyright 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation.
This file is part of the MPFR Library.
@@ -21,6 +21,10 @@ MA 02111-1307, USA. */
#include "mpfr-impl.h"
+/* Note: In case of even rounding when rnd = GMP_RNDN, MPFR_EVEN_INEX (2)
+ or -MPFR_EVEN_INEX (-2) is returned. This is used internally. This is
+ no longer valid in the CVS trunk. */
+
/* set a to abs(b) * signb: a=b when signb = SIGN(b), a=abs(b) when signb=1 */
int
mpfr_set4 (mpfr_ptr a, mpfr_srcptr b, mp_rnd_t rnd_mode, int signb)
diff --git a/set_d.c b/set_d.c
index b9c3cba0d..012d09543 100644
--- a/set_d.c
+++ b/set_d.c
@@ -21,6 +21,7 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
#include <string.h> /* For memcmp if _GMP_IEEE_FLOAT == 0 */
+#include <float.h> /* For DOUBLE_ISINF and DOUBLE_ISNAN */
#define MPFR_NEED_LONGLONG_H
#include "mpfr-impl.h"
diff --git a/set_str.c b/set_str.c
index 302fa6fb5..60e073124 100644
--- a/set_str.c
+++ b/set_str.c
@@ -25,6 +25,10 @@ MA 02111-1307, USA. */
#define MPFR_NEED_LONGLONG_H
#include "mpfr-impl.h"
+
+/* Old code */
+#if 0
+
#include "log_b2.h"
static double __gmpfr_ceil _MPFR_PROTO((double));
@@ -384,6 +388,19 @@ mpfr_set_str (mpfr_t x, const char *str, int base, mp_rnd_t rnd)
return res;
}
+#endif
+
+int
+mpfr_set_str (mpfr_t x, const char *str, int base, mp_rnd_t rnd)
+{
+ char *p;
+
+ if (MPFR_UNLIKELY (*str == 0))
+ return -1;
+ mpfr_strtofr (x, str, &p, base, rnd);
+ return (*p == 0) ? 0 : -1;
+}
+
int
mpfr_init_set_str (mpfr_ptr x, const char *str, int base, mp_rnd_t rnd)
diff --git a/strtofr.c b/strtofr.c
index 01d77ec63..f99f1dca8 100644
--- a/strtofr.c
+++ b/strtofr.c
@@ -125,22 +125,22 @@ int main ()
mpfr_ui_div (x, 1, x, GMP_RNDN);
printf ("Base: %d x=%e ", base, mpfr_get_d1 (x));
for (i = 0 ; i < N ; i++)
- {
- mpfr_floor (y, x);
- tab[i] = mpfr_get_ui (y, GMP_RNDN);
- mpfr_sub (x, x, y, GMP_RNDN);
- mpfr_ui_div (x, 1, x, GMP_RNDN);
- }
+ {
+ mpfr_floor (y, x);
+ tab[i] = mpfr_get_ui (y, GMP_RNDN);
+ mpfr_sub (x, x, y, GMP_RNDN);
+ mpfr_ui_div (x, 1, x, GMP_RNDN);
+ }
for (i = N-1 ; i >= 0 ; i--)
- if (tab[i] != 0)
- break;
+ if (tab[i] != 0)
+ break;
mpq_set_ui (q1, tab[i], 1);
for (i = i-1 ; i >= 0 ; i--)
- {
- mpq_inv (q1, q1);
- mpq_set_ui (q2, tab[i], 1);
- mpq_add (q1, q1, q2);
- }
+ {
+ mpq_inv (q1, q1);
+ mpq_set_ui (q2, tab[i], 1);
+ mpq_add (q1, q1, q2);
+ }
printf("Approx: ", base);
mpq_out_str (stdout, 10, q1);
printf (" = %e\n", mpq_get_d (q1) );
@@ -150,10 +150,10 @@ int main ()
mpz_out_str (stderr, 10, mpq_denref (q1));
fprintf (stderr, "UL},\n");
if (mpz_cmp_ui (mpq_numref (q1), 1<<16-1) >= 0
- || mpz_cmp_ui (mpq_denref (q1), 1<<16-1) >= 0)
- overflow = 1, base_overflow = base;
+ || mpz_cmp_ui (mpq_denref (q1), 1<<16-1) >= 0)
+ overflow = 1, base_overflow = base;
}
-
+
mpq_clear (q2);
mpq_clear (q1);
mpfr_clear (y);
@@ -182,7 +182,7 @@ digit_value_in_base (int c, int base)
digit = c - 'A' + 10;
else
return -1;
-
+
return MPFR_LIKELY (digit < base) ? digit : -1;
}
@@ -191,27 +191,27 @@ digit_value_in_base (int c, int base)
It returns:
-1 if invalid string,
0 if special string (like nan),
- 1 if the string is ok.
+ 1 if the string is ok.
2 if overflows
3 if underflows
So it doesn't return the ternary value
BUT if it returns 0 (NAN or INF), the ternary value is also '0'
(ie NAN and INF are exact) */
static int
-parse_string (mpfr_t x, struct parsed_string *pstr,
- const char **string, int base)
+parse_string (mpfr_t x, struct parsed_string *pstr,
+ const char **string, int base)
{
const char *str = *string;
unsigned char *mant;
int point;
int res = -1; /* Invalid input return value */
const char *prefix_str;
-
+
/* Init variable */
pstr->mantissa = NULL;
/* Optional leading whitespace */
- while (isspace(*str)) str++;
+ while (isspace((unsigned char) *str)) str++;
/* Can be case-insensitive NAN */
if (strncasecmp (str, "@nan@", 5) == 0)
@@ -225,17 +225,17 @@ parse_string (mpfr_t x, struct parsed_string *pstr,
set_nan:
/* Check for "(dummychars)" */
if (*str == '(')
- {
- const char *s;
- for (s = str+1 ; *s != ')' ; s++)
- if (!(*s >= 'A' && *s <= 'Z')
- && !(*s >= 'a' && *s <= 'z')
- && !(*s >= '0' && *s <= '9')
- && *s != '_')
- break;
- if (*s == ')')
- str = s+1;
- }
+ {
+ const char *s;
+ for (s = str+1 ; *s != ')' ; s++)
+ if (!(*s >= 'A' && *s <= 'Z')
+ && !(*s >= 'a' && *s <= 'z')
+ && !(*s >= '0' && *s <= '9')
+ && *s != '_')
+ break;
+ if (*s == ')')
+ str = s+1;
+ }
*string = str;
MPFR_SET_NAN(x);
/* MPFR_RET_NAN not used as the return value isn't a ternary value */
@@ -267,18 +267,20 @@ parse_string (mpfr_t x, struct parsed_string *pstr,
MPFR_SET_INF (x);
(pstr->negative) ? MPFR_SET_NEG (x) : MPFR_SET_POS (x);
return 0;
- }
+ }
/* If base=0 or 16, it may include '0x' prefix */
prefix_str = NULL;
- if ((base == 0 || base == 16) && str[0]=='0' && str[1]=='x')
+ if ((base == 0 || base == 16) && str[0]=='0'
+ && (str[1]=='x' || str[1] == 'X'))
{
prefix_str = str;
base = 16;
str += 2;
}
/* If base=0 or 2, it may include '0b' prefix */
- if ((base == 0 || base == 2) && str[0]=='0' && str[1]=='b')
+ if ((base == 0 || base == 2) && str[0]=='0'
+ && (str[1]=='b' || str[1] == 'B'))
{
prefix_str = str;
base = 2;
@@ -305,15 +307,15 @@ parse_string (mpfr_t x, struct parsed_string *pstr,
int c = *str++;
if (c == '.')
{
- if (MPFR_UNLIKELY(point)) /* Second '.': stop parsing */
- break;
+ if (MPFR_UNLIKELY(point)) /* Second '.': stop parsing */
+ break;
point = 1;
continue;
}
c = digit_value_in_base (c, base);
if (c == -1)
- break;
- *mant++ = (char) c;
+ break;
+ *mant++ = (char) c;
if (!point)
pstr->exp_base ++;
}
@@ -325,46 +327,47 @@ parse_string (mpfr_t x, struct parsed_string *pstr,
if (pstr->prec == 0)
{
/* Check if there was a prefix (in such a case, we have to read
- again the mantissa without skipping the prefix)
- The allocated mantissa is still enought big since we will
- read only 0, and we alloc one more char than needed.
- FIXME: Not really friendly. Maybe cleaner code? */
+ again the mantissa without skipping the prefix)
+ The allocated mantissa is still enought big since we will
+ read only 0, and we alloc one more char than needed.
+ FIXME: Not really friendly. Maybe cleaner code? */
if (prefix_str != NULL)
- {
- str = prefix_str;
- prefix_str = NULL;
- goto parse_begin;
- }
+ {
+ str = prefix_str;
+ prefix_str = NULL;
+ goto parse_begin;
+ }
goto end;
}
/* Valid entry */
- res = 1;
+ res = 1;
/* an optional exponent (e or E, p or P, @) */
- if ( (*str == '@' || (base <= 10 && (*str == 'e' || *str == 'E')))
- && (!isspace(str[1])) )
+ if ( (*str == '@' || (base <= 10 && (*str == 'e' || *str == 'E')))
+ && (!isspace((unsigned char) str[1])) )
{
char *endptr[1];
/* the exponent digits are kept in ASCII */
mp_exp_t read_exp = strtol (str + 1, endptr, 10);
mp_exp_t sum = 0;
if (endptr[0] != str+1)
- str = endptr[0];
+ str = endptr[0];
MPFR_ASSERTN (read_exp == (long) read_exp);
MPFR_SADD_OVERFLOW (sum, read_exp, pstr->exp_base,
- mp_exp_t, mp_exp_unsigned_t,
- MPFR_EXP_MIN, MPFR_EXP_MAX,
- res = 2, res = 3);
+ mp_exp_t, mp_exp_unsigned_t,
+ MPFR_EXP_MIN, MPFR_EXP_MAX,
+ res = 2, res = 3);
pstr->exp_base = sum;
}
else if ((base == 2 || base == 16)
- && (*str == 'p' || *str == 'P') && (!isspace(str[1])))
+ && (*str == 'p' || *str == 'P')
+ && (!isspace((unsigned char) str[1])))
{
char *endptr[1];
pstr->exp_bin = (mp_exp_t) strtol (str + 1, endptr, 10);
if (endptr[0] != str+1)
- str = endptr[0];
+ str = endptr[0];
}
/* Remove 0's at the beginning and end of mant_s[0..prec_s-1] */
@@ -390,7 +393,7 @@ parse_string (mpfr_t x, struct parsed_string *pstr,
if (pstr->mantissa != NULL && res != 1)
(*__gmp_free_func) (pstr->mantissa, pstr->alloc);
return res;
-}
+}
/* Transform a parsed string to a mpfr_t according to the rounding mode
and the precision of x.
@@ -406,7 +409,7 @@ parsed_string_to_mpfr (mpfr_t x, struct parsed_string *pstr, mp_rnd_t rnd)
size_t pstr_size;
mp_size_t ysize, real_ysize;
int res, err;
- TMP_DECL (maker);
+ TMP_DECL (marker);
/* determine the minimal precision for the computation */
prec = MPFR_PREC (x) + MPFR_INT_CEIL_LOG2 (MPFR_PREC (x));
@@ -420,27 +423,27 @@ parsed_string_to_mpfr (mpfr_t x, struct parsed_string *pstr, mp_rnd_t rnd)
ysize_bits = ysize * BITS_PER_MP_LIMB;
y = (mp_limb_t*) TMP_ALLOC ((2 * ysize + 1) * sizeof (mp_limb_t));
y += ysize;
-
- /* required precision for str to have ~ysize limbs
- We must have (2^(BITS_PER_MP_LIMB))^ysize ~= base^pstr_size
- aka pstr_size = ceil (ysize*BITS_PER_MP_LIMB/log2(base))
- ysize ~ prec/BITS_PER_MP_LIMB and prec < Umax/2 =>
- ysize*BITS_PER_MP_LIMB can not overflow.
- Compute pstr_size = ysize_bits * Num / Den
- Where Num/Den ~ 1/log2(base)
- It is not exactly ceil(1/log2(base)) but could be one more (base 2)
- Quite ugly since it tries to avoid overflow */
+
+ /* required precision for str to have ~ysize limbs
+ We must have (2^(BITS_PER_MP_LIMB))^ysize ~= base^pstr_size
+ aka pstr_size = ceil (ysize*BITS_PER_MP_LIMB/log2(base))
+ ysize ~ prec/BITS_PER_MP_LIMB and prec < Umax/2 =>
+ ysize*BITS_PER_MP_LIMB can not overflow.
+ Compute pstr_size = ysize_bits * Num / Den
+ Where Num/Den ~ 1/log2(base)
+ It is not exactly ceil(1/log2(base)) but could be one more (base 2)
+ Quite ugly since it tries to avoid overflow */
pstr_size = ( ysize_bits / RedInvLog2Table[pstr->base-2][1]
- * RedInvLog2Table[pstr->base-2][0] )
- + (( ysize_bits % RedInvLog2Table[pstr->base-2][1])
- * RedInvLog2Table[pstr->base-2][0]
- / RedInvLog2Table[pstr->base-2][1] )
- + 1;
+ * RedInvLog2Table[pstr->base-2][0] )
+ + (( ysize_bits % RedInvLog2Table[pstr->base-2][1])
+ * RedInvLog2Table[pstr->base-2][0]
+ / RedInvLog2Table[pstr->base-2][1] )
+ + 1;
if (pstr_size >= pstr->prec)
pstr_size = pstr->prec;
MPFR_ASSERTD ((mp_exp_t) pstr_size == (mp_exp_t) pstr_size);
-
+
/* convert str into binary */
real_ysize = mpn_set_str (y, pstr->mant, pstr_size, pstr->base);
MPFR_ASSERTD ( real_ysize <= ysize+1);
@@ -461,13 +464,13 @@ parsed_string_to_mpfr (mpfr_t x, struct parsed_string *pstr, mp_rnd_t rnd)
MPN_ZERO (y, ysize - real_ysize);
}
/* for each bit shift decrease exponent of y */
- /* (This should not overflow) */
+ /* (This should not overflow) */
exp = - ((ysize - real_ysize) * BITS_PER_MP_LIMB + count);
}
else /* shift y for the right */
{
/* shift {y, num_limb} for (BITS_PER_MP_LIMB - count) bits
- to the right */
+ to the right */
mpn_rshift (y, y, real_ysize, BITS_PER_MP_LIMB - count);
/* for each bit shift increase exponent of y */
exp = BITS_PER_MP_LIMB - count;
@@ -476,53 +479,53 @@ parsed_string_to_mpfr (mpfr_t x, struct parsed_string *pstr, mp_rnd_t rnd)
/* compute base^(exp_s-pr) on n limbs */
if (IS_POW2 (pstr->base))
{
- /* Base: 2, 4, 8, 16, 32 */
+ /* Base: 2, 4, 8, 16, 32 */
int pow2;
- mp_exp_t tmp;
+ mp_exp_t tmp;
count_leading_zeros (pow2, (mp_limb_t) pstr->base);
pow2 = BITS_PER_MP_LIMB - pow2 - 1; /* base = 2^pow2 */
- MPFR_ASSERTD (0 < pow2 && pow2 <= 5);
- /* exp += pow2 * (pstr->exp_base - pstr_size) + pstr->exp_bin
- with overflow checking
- and check that we can add/substract 2 to exp without overflow */
- MPFR_SADD_OVERFLOW (tmp, pstr->exp_base, -(mp_exp_t) pstr_size,
- mp_exp_t, mp_exp_unsigned_t,
- MPFR_EXP_MIN, MPFR_EXP_MAX,
- goto overflow, goto underflow);
- /* On some FreeBsd/Alpha, LONG_MIN/1 produces an exception
- so we check for this before doing the division */
- if (tmp > 0 && pow2 != 1 && MPFR_EXP_MAX/pow2 <= tmp)
- goto overflow;
- else if (tmp < 0 && pow2 != 1 && MPFR_EXP_MIN/pow2 >= tmp)
- goto underflow;
- tmp *= pow2;
- MPFR_SADD_OVERFLOW (tmp, tmp, pstr->exp_bin,
- mp_exp_t, mp_exp_unsigned_t,
- MPFR_EXP_MIN, MPFR_EXP_MAX,
- goto overflow, goto underflow);
- MPFR_SADD_OVERFLOW (exp, exp, tmp,
- mp_exp_t, mp_exp_unsigned_t,
- MPFR_EXP_MIN+2, MPFR_EXP_MAX-2,
- goto overflow, goto underflow);
- result = y;
- err = 0;
+ MPFR_ASSERTD (0 < pow2 && pow2 <= 5);
+ /* exp += pow2 * (pstr->exp_base - pstr_size) + pstr->exp_bin
+ with overflow checking
+ and check that we can add/substract 2 to exp without overflow */
+ MPFR_SADD_OVERFLOW (tmp, pstr->exp_base, -(mp_exp_t) pstr_size,
+ mp_exp_t, mp_exp_unsigned_t,
+ MPFR_EXP_MIN, MPFR_EXP_MAX,
+ goto overflow, goto underflow);
+ /* On some FreeBsd/Alpha, LONG_MIN/1 produces an exception
+ so we check for this before doing the division */
+ if (tmp > 0 && pow2 != 1 && MPFR_EXP_MAX/pow2 <= tmp)
+ goto overflow;
+ else if (tmp < 0 && pow2 != 1 && MPFR_EXP_MIN/pow2 >= tmp)
+ goto underflow;
+ tmp *= pow2;
+ MPFR_SADD_OVERFLOW (tmp, tmp, pstr->exp_bin,
+ mp_exp_t, mp_exp_unsigned_t,
+ MPFR_EXP_MIN, MPFR_EXP_MAX,
+ goto overflow, goto underflow);
+ MPFR_SADD_OVERFLOW (exp, exp, tmp,
+ mp_exp_t, mp_exp_unsigned_t,
+ MPFR_EXP_MIN+2, MPFR_EXP_MAX-2,
+ goto overflow, goto underflow);
+ result = y;
+ err = 0;
}
/* case pstr->exp_base > pstr_size */
else if (pstr->exp_base > (mp_exp_t) pstr_size)
{
- mp_limb_t *z;
- mp_exp_t exp_z;
-
+ mp_limb_t *z;
+ mp_exp_t exp_z;
+
result = (mp_limb_t*) TMP_ALLOC ((2*ysize+1)*BYTES_PER_MP_LIMB);
/* z = base^(exp_base-sptr_size) using space allocated at y-ysize */
z = y - ysize;
- /* NOTE: exp_base-pstr_size can't overflow since pstr_size > 0 */
- err = mpfr_mpn_exp (z, &exp_z, pstr->base,
- pstr->exp_base - pstr_size, ysize);
+ /* NOTE: exp_base-pstr_size can't overflow since pstr_size > 0 */
+ err = mpfr_mpn_exp (z, &exp_z, pstr->base,
+ pstr->exp_base - pstr_size, ysize);
if (err == -2)
- goto overflow;
+ goto overflow;
exact = exact && (err == -1);
/* multiply(y = 0.mant_s[0]...mant_s[pr-1])_base by base^(exp_s-g) */
@@ -534,35 +537,35 @@ parsed_string_to_mpfr (mpfr_t x, struct parsed_string *pstr, mp_rnd_t rnd)
err ++;
/* compute the exponent of y */
- /* exp += exp_z + ysize_bits with overflow checking
- and check that we can add/substract 2 to exp without overflow */
- MPFR_SADD_OVERFLOW (exp_z, exp_z, ysize_bits,
- mp_exp_t, mp_exp_unsigned_t,
- MPFR_EXP_MIN, MPFR_EXP_MAX,
- goto overflow, goto underflow);
- MPFR_SADD_OVERFLOW (exp, exp, exp_z,
- mp_exp_t, mp_exp_unsigned_t,
- MPFR_EXP_MIN+2, MPFR_EXP_MAX-2,
- goto overflow, goto underflow);
+ /* exp += exp_z + ysize_bits with overflow checking
+ and check that we can add/substract 2 to exp without overflow */
+ MPFR_SADD_OVERFLOW (exp_z, exp_z, ysize_bits,
+ mp_exp_t, mp_exp_unsigned_t,
+ MPFR_EXP_MIN, MPFR_EXP_MAX,
+ goto overflow, goto underflow);
+ MPFR_SADD_OVERFLOW (exp, exp, exp_z,
+ mp_exp_t, mp_exp_unsigned_t,
+ MPFR_EXP_MIN+2, MPFR_EXP_MAX-2,
+ goto overflow, goto underflow);
/* normalize result */
if (MPFR_LIMB_MSB (result[2 * ysize - 1]) == 0)
{
- mp_limb_t *r = result + ysize - 1;
+ mp_limb_t *r = result + ysize - 1;
mpn_lshift (r, r, ysize + 1, 1);
- /* Overflow checking not needed */
+ /* Overflow checking not needed */
exp --;
}
- exact = exact && (mpn_scan1 (result, 0)
- >= (unsigned long) ysize_bits);
- result += ysize;
+ exact = exact && (mpn_scan1 (result, 0)
+ >= (unsigned long) ysize_bits);
+ result += ysize;
}
/* case exp_base < pstr_size */
else if (pstr->exp_base < (mp_exp_t) pstr_size)
{
- mp_limb_t *z;
- mp_exp_t exp_z;
+ mp_limb_t *z;
+ mp_exp_t exp_z;
result = (mp_limb_t*) TMP_ALLOC ( (3*ysize+1) * BYTES_PER_MP_LIMB);
@@ -570,63 +573,63 @@ parsed_string_to_mpfr (mpfr_t x, struct parsed_string *pstr, mp_rnd_t rnd)
y = y - ysize; /* we have allocated ysize limbs at y - ysize */
MPN_ZERO (y, ysize);
- /* pstr_size - pstr->exp_base can overflow */
- MPFR_SADD_OVERFLOW (exp_z, (mp_exp_t) pstr_size, -pstr->exp_base,
- mp_exp_t, mp_exp_unsigned_t,
- MPFR_EXP_MIN, MPFR_EXP_MAX,
- goto underflow, goto overflow);
+ /* pstr_size - pstr->exp_base can overflow */
+ MPFR_SADD_OVERFLOW (exp_z, (mp_exp_t) pstr_size, -pstr->exp_base,
+ mp_exp_t, mp_exp_unsigned_t,
+ MPFR_EXP_MIN, MPFR_EXP_MAX,
+ goto underflow, goto overflow);
/* (z, exp_z) = base^(exp_base-pstr_size) */
- z = result + 2*ysize + 1;
+ z = result + 2*ysize + 1;
err = mpfr_mpn_exp (z, &exp_z, pstr->base, exp_z, ysize);
exact = exact && (err == -1);
- if (err == -2)
- goto underflow; /* FIXME: Sure? */
+ if (err == -2)
+ goto underflow; /* FIXME: Sure? */
if (err == -1)
err = 0;
/* compute y / z */
/* result will be put into result + n, and remainder into result */
- mpn_tdiv_qr (result + ysize, result, (mp_size_t) 0, y,
- 2*ysize, z, ysize);
-
- /* exp -= exp_z + ysize_bits with overflow checking
- and check that we can add/substract 2 to exp without overflow */
- MPFR_SADD_OVERFLOW (exp_z, exp_z, ysize_bits,
- mp_exp_t, mp_exp_unsigned_t,
- MPFR_EXP_MIN, MPFR_EXP_MAX,
- goto underflow, goto overflow);
- MPFR_SADD_OVERFLOW (exp, exp, -exp_z,
- mp_exp_t, mp_exp_unsigned_t,
- MPFR_EXP_MIN+2, MPFR_EXP_MAX-2,
- goto overflow, goto underflow);
+ mpn_tdiv_qr (result + ysize, result, (mp_size_t) 0, y,
+ 2*ysize, z, ysize);
+
+ /* exp -= exp_z + ysize_bits with overflow checking
+ and check that we can add/substract 2 to exp without overflow */
+ MPFR_SADD_OVERFLOW (exp_z, exp_z, ysize_bits,
+ mp_exp_t, mp_exp_unsigned_t,
+ MPFR_EXP_MIN, MPFR_EXP_MAX,
+ goto underflow, goto overflow);
+ MPFR_SADD_OVERFLOW (exp, exp, -exp_z,
+ mp_exp_t, mp_exp_unsigned_t,
+ MPFR_EXP_MIN+2, MPFR_EXP_MAX-2,
+ goto overflow, goto underflow);
err += 2;
exact = exact && (mpn_popcount (result, ysize) == 0);
/* normalize result */
if (result[2 * ysize] == MPFR_LIMB_ONE)
{
- mp_limb_t *r = result + ysize;
+ mp_limb_t *r = result + ysize;
exact = exact && ((*r & MPFR_LIMB_ONE) == 0);
mpn_rshift (r, r, ysize + 1, 1);
- /* Overflow Checking not needed */
+ /* Overflow Checking not needed */
exp ++;
}
- result += ysize;
+ result += ysize;
}
/* case exp_base = pstr_size */
else
{
/* base^(exp_s-pr) = 1 nothing to compute */
result = y;
- err = 0;
+ err = 0;
}
/* test if rounding is possible, and if so exit the loop */
- if (exact || mpfr_can_round_raw (result, ysize,
- (pstr->negative) ? -1 : 1,
- ysize_bits - err - 1,
- GMP_RNDN, rnd, MPFR_PREC(x)))
+ if (exact || mpfr_can_round_raw (result, ysize,
+ (pstr->negative) ? -1 : 1,
+ ysize_bits - err - 1,
+ GMP_RNDN, rnd, MPFR_PREC(x)))
break;
/* update the prec for next loop */
@@ -635,8 +638,8 @@ parsed_string_to_mpfr (mpfr_t x, struct parsed_string *pstr, mp_rnd_t rnd)
/* round y */
if (mpfr_round_raw (MPFR_MANT (x), result,
- ysize_bits,
- pstr->negative, MPFR_PREC(x), rnd, &res ))
+ ysize_bits,
+ pstr->negative, MPFR_PREC(x), rnd, &res ))
{
/* overflow when rounding y */
MPFR_MANT (x)[MPFR_LIMB_SIZE (x) - 1] = MPFR_LIMB_HIGHBIT;
@@ -649,26 +652,26 @@ parsed_string_to_mpfr (mpfr_t x, struct parsed_string *pstr, mp_rnd_t rnd)
/* DO NOT USE MPFR_SET_EXP. The exp may be out of range! */
MPFR_SADD_OVERFLOW (exp, exp, ysize_bits,
- mp_exp_t, mp_exp_unsigned_t,
- MPFR_EXP_MIN, MPFR_EXP_MAX,
- goto overflow, goto underflow);
+ mp_exp_t, mp_exp_unsigned_t,
+ MPFR_EXP_MIN, MPFR_EXP_MAX,
+ goto overflow, goto underflow);
MPFR_EXP (x) = exp;
res = mpfr_check_range (x, res, rnd);
goto end;
underflow:
- /* This is called when there is a huge overflow
+ /* This is called when there is a huge overflow
(Real expo < MPFR_EXP_MIN << __gmpfr_emin */
if (rnd == GMP_RNDN)
rnd = GMP_RNDZ;
res = mpfr_set_underflow (x, rnd, (pstr->negative) ? -1 : 1);
goto end;
-
+
overflow:
res = mpfr_set_overflow (x, rnd, (pstr->negative) ? -1 : 1);
end:
- TMP_FREE (maker);
+ TMP_FREE (marker);
return res;
}
@@ -679,8 +682,8 @@ free_parsed_string (struct parsed_string *pstr)
}
int
-mpfr_strtofr (mpfr_t x, const char *string, char **end, unsigned int base,
- mp_rnd_t rnd)
+mpfr_strtofr (mpfr_t x, const char *string, char **end, int base,
+ mp_rnd_t rnd)
{
int res = -1;
struct parsed_string pstr;
@@ -689,26 +692,26 @@ mpfr_strtofr (mpfr_t x, const char *string, char **end, unsigned int base,
MPFR_SET_ZERO (x);
MPFR_SET_POS (x);
- if (base == 0 || (base >= 2 && base <= MPFR_MAX_BASE))
+ if (base == 0 || (base >= 2 && base <= /*MPFR_MAX_BASE*/36))
{
res = parse_string (x, &pstr, &string, base);
/* If res == 0, then it was exact (NAN or INF),
- so it is also the ternary value */
+ so it is also the ternary value */
if (res == 1)
- {
- res = parsed_string_to_mpfr (x, &pstr, rnd);
- free_parsed_string (&pstr);
- }
+ {
+ res = parsed_string_to_mpfr (x, &pstr, rnd);
+ free_parsed_string (&pstr);
+ }
else if (res == 2)
- res = mpfr_set_overflow (x, rnd, (pstr.negative) ? -1 : 1);
+ res = mpfr_set_overflow (x, rnd, (pstr.negative) ? -1 : 1);
else if (res == 3)
- {
- /* This is called when there is a huge overflow
- (Real expo < MPFR_EXP_MIN << __gmpfr_emin */
- if (rnd == GMP_RNDN)
- rnd = GMP_RNDZ;
- res = mpfr_set_underflow (x, rnd, (pstr.negative) ? -1 : 1);
- }
+ {
+ /* This is called when there is a huge overflow
+ (Real expo < MPFR_EXP_MIN << __gmpfr_emin */
+ if (rnd == GMP_RNDN)
+ rnd = GMP_RNDZ;
+ res = mpfr_set_underflow (x, rnd, (pstr.negative) ? -1 : 1);
+ }
}
if (end != NULL)
*end = (char *) string;
diff --git a/sub1.c b/sub1.c
index 6bdbebcc3..4d57eb313 100644
--- a/sub1.c
+++ b/sub1.c
@@ -1,6 +1,6 @@
/* mpfr_sub1 -- internal function to perform a "real" subtraction
-Copyright 2001, 2002, 2003, 2004 Free Software Foundation.
+Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation.
Contributed by the Spaces project, INRIA Lorraine.
This file is part of the MPFR Library.
@@ -20,7 +20,6 @@ along with the MPFR Library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
-
#include "mpfr-impl.h"
/* compute sign(b) * (|b| - |c|), with |b| > |c|, diff_exp = EXP(b) - EXP(c)
@@ -81,6 +80,60 @@ mpfr_sub1 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
else
MPFR_SET_SAME_SIGN(a,b);
+ /* Check if c is too small.
+ A more precise test is to replace 2 by
+ (rnd == GMP_RNDN) + mpfr_power2_raw (b)
+ but it is more expensive and not very usefull */
+ if (MPFR_UNLIKELY (MPFR_GET_EXP (c) <= MPFR_GET_EXP (b)
+ - (mp_exp_t) MAX (MPFR_PREC (a), MPFR_PREC (b)) - 2))
+ {
+ /* Remember, we can't have an exact result! */
+ /* A.AAAAAAAAAAAAAAAAA
+ = B.BBBBBBBBBBBBBBB
+ - C.CCCCCCCCCCCCC */
+ /* A = S*ABS(B) +/- ulp(a) */
+ inexact = mpfr_set4 (a, b, rnd_mode, MPFR_SIGN (a));
+ if (inexact == 0)
+ {
+ /* a = b (Exact)
+ But we know it isn't (Since we have to remove `c')
+ So if we round to Zero, we have to remove one ulp.
+ Otherwise the result is correctly rounded. */
+ if (MPFR_IS_LIKE_RNDZ (rnd_mode, MPFR_IS_NEG (a))) {
+ (MPFR_IS_POS (a) ? mpfr_nextbelow : mpfr_nextabove) (a);
+ return -MPFR_INT_SIGN (a);
+ }
+ return MPFR_INT_SIGN (a);
+ }
+ else
+ {
+ /* A.AAAAAAAAAAAAAA
+ = B.BBBBBBBBBBBBBBB
+ - C.CCCCCCCCCCCCC */
+ /* It isn't exact so Prec(b) > Prec(a) and the last
+ Prec(b)-Prec(a) bits of `b' are not zeros.
+ Which means that removing c from b can't generate a carry
+ execpt in case of even rounding.
+ In all other case the result and the inexact flag should be
+ correct (We can't have an exact result).
+ In case of EVEN rounding:
+ 1.BBBBBBBBBBBBBx10
+ - 1.CCCCCCCCCCCC
+ = 1.BBBBBBBBBBBBBx01 Rounded to Prec(b)
+ = 1.BBBBBBBBBBBBBx Nearest / Rounded to Prec(a)
+ Set gives:
+ 1.BBBBBBBBBBBBB0 if inexact == EVEN_INEX (x == 0)
+ 1.BBBBBBBBBBBBB1+1 if inexact == -EVEN_INEX (x == 1)
+ which means we get a wrong rounded result if x==1,
+ i.e. inexact= MPFR_EVEN_INEX */
+ if (MPFR_UNLIKELY (inexact == MPFR_EVEN_INEX*MPFR_INT_SIGN (a))) {
+ (MPFR_IS_POS (a) ? mpfr_nextbelow : mpfr_nextabove) (a);
+ inexact = -MPFR_INT_SIGN (a);
+ }
+ return inexact;
+ }
+ }
+
diff_exp = (mp_exp_unsigned_t) MPFR_GET_EXP (b) - MPFR_GET_EXP (c);
/* reserve a space to store b aligned with the result, i.e. shifted by
@@ -136,19 +189,20 @@ mpfr_sub1 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
}
#ifdef DEBUG
- printf("shift_b=%u shift_c=%u\n", shift_b, shift_c);
+ printf("shift_b=%u shift_c=%u diffexp=%lu\n", shift_b, shift_c, diff_exp);
#endif
MPFR_ASSERTD (ap != cp);
MPFR_ASSERTD (bp != cp);
/* here we have shift_c = (diff_exp - cancel) % BITS_PER_MP_LIMB,
+ 0 <= shift_c < BITS_PER_MP_LIMB
thus we want cancel2 = ceil((cancel - diff_exp) / BITS_PER_MP_LIMB) */
cancel2 = (long int) (cancel - (diff_exp - shift_c)) / BITS_PER_MP_LIMB;
/* the high cancel2 limbs from b should not be taken into account */
#ifdef DEBUG
- printf("cancel=%u cancel1=%u cancel2=%d\n", cancel, cancel1, cancel2);
+ printf("cancel=%lu cancel1=%lu cancel2=%ld\n", cancel, cancel1, cancel2);
#endif
/* ap[an-1] ap[0]
@@ -276,6 +330,7 @@ mpfr_sub1 (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
bn -= an + cancel1;
cn0 = cn;
cn -= (long int) an + cancel2;
+
#ifdef DEBUG
printf("last %d bits from a are %lu, bn=%ld, cn=%ld\n", sh, carry, bn, cn);
#endif
diff --git a/sum.c b/sum.c
index 9f1824ee7..6b0356f03 100644
--- a/sum.c
+++ b/sum.c
@@ -1,6 +1,6 @@
/* Sum -- efficiently sum a list of floating-point numbers
-Copyright 2004 Free Software Foundation, Inc.
+Copyright 2004, 2005 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -67,7 +67,7 @@ void mpfr_count_sort (mpfr_ptr const tab[], unsigned long n,
perm[target_rank] = tab[i];
}
- TMP_FREE(account);
+ TMP_FREE(marker);
}
/* Performs a heap sort of the entries */
@@ -169,17 +169,18 @@ static int mpfr_list_sum_once (mpfr_ptr ret, mpfr_srcptr const tab[],
{
unsigned long i;
mpfr_t sum;
- int error_trap = 0;
+ int error_trap;
+
+ if (MPFR_UNLIKELY (n == 1))
+ return mpfr_set (ret, tab[0], GMP_RNDN);
mpfr_init2 (sum, F);
- mpfr_set (sum, tab[0], GMP_RNDN);
+ error_trap = mpfr_set (sum, tab[0], GMP_RNDN);
for (i = 1; i < n - 1; i++)
- {
- error_trap |= mpfr_add (sum, sum, tab[i], GMP_RNDN);
- }
-
+ error_trap |= mpfr_add (sum, sum, tab[i], GMP_RNDN);
error_trap |= mpfr_add (ret, sum, tab[n - 1], GMP_RNDN);
+
mpfr_clear (sum);
return error_trap;
}
@@ -201,12 +202,17 @@ int mpfr_sum (mpfr_ptr ret, mpfr_ptr const tab[], unsigned long n,
TMP_DECL(marker);
TMP_MARK(marker);
+ if (MPFR_UNLIKELY (n == 0)) {
+ MPFR_SET_ZERO (ret);
+ MPFR_SET_POS (ret);
+ return 0;
+ }
perm = (mpfr_srcptr *) TMP_ALLOC(n * sizeof(mpfr_srcptr));
mpfr_count_sort (tab, n, perm);
- initial_f = MPFR_PREC(tab[0]);
+ initial_f = MAX (MPFR_PREC(tab[0]), MPFR_PREC(ret));
k = __gmpfr_ceil_log2 ((double) n) + 1;
mpfr_init2 (cur_sum, initial_f);
initial_guard_digits = k + 2;
@@ -221,7 +227,7 @@ int mpfr_sum (mpfr_ptr ret, mpfr_ptr const tab[], unsigned long n,
}
while ((error_trap != 0) &&
!(mpfr_can_round (cur_sum, MPFR_GET_EXP(cur_sum) - current_f + 2,
- GMP_RNDN, rnd, initial_f)));
+ GMP_RNDN, rnd, MPFR_PREC(ret))));
error_trap |= mpfr_set (ret, cur_sum, rnd);
mpfr_clear (cur_sum);
TMP_FREE(marker);
diff --git a/tan.c b/tan.c
index 2eabba089..672b6e407 100644
--- a/tan.c
+++ b/tan.c
@@ -1,6 +1,6 @@
/* mpfr_tan -- tangent of a floating-point number
-Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -44,6 +44,9 @@ mpfr_tan (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode)
}
}
+ mpfr_save_emin_emax ();
+
+ /* Compute initial precision */
precy = MPFR_PREC(y);
m = precy + __gmpfr_ceil_log2 ((double) precy)
+ ABS (MPFR_GET_EXP (x)) + 13;
@@ -53,10 +56,13 @@ mpfr_tan (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode)
for (;;)
{
+ /* The only way to get an overflow is to get ~ Pi/2
+ But the result will be ~ 2^Prec(y). */
mpfr_sin_cos (s, c, x, GMP_RNDN); /* err <= 1/2 ulp on s and c */
mpfr_div (c, s, c, GMP_RNDN); /* err <= 2 ulps */
- if (MPFR_IS_INF(x) || mpfr_can_round (c, m - 1, GMP_RNDN, GMP_RNDZ,
- precy + (rnd_mode == GMP_RNDN)))
+ MPFR_ASSERTD (!MPFR_IS_SINGULAR (c));
+ if (MPFR_LIKELY (mpfr_can_round (c, m - 1, GMP_RNDN, GMP_RNDZ,
+ precy + (rnd_mode == GMP_RNDN))))
break;
m += BITS_PER_MP_LIMB;
mpfr_set_prec (s, m);
@@ -68,5 +74,6 @@ mpfr_tan (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode)
mpfr_clear (s);
mpfr_clear (c);
- return inexact;
+ mpfr_restore_emin_emax ();
+ return mpfr_check_range (y, inexact, rnd_mode);
}
diff --git a/tests/Makefile.in b/tests/Makefile.in
deleted file mode 100644
index 4cdbe3005..000000000
--- a/tests/Makefile.in
+++ /dev/null
@@ -1,920 +0,0 @@
-# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am
-
-# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
-
-SHELL = @SHELL@
-
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-VPATH = @srcdir@
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-
-bindir = @bindir@
-sbindir = @sbindir@
-libexecdir = @libexecdir@
-datadir = @datadir@
-sysconfdir = @sysconfdir@
-sharedstatedir = @sharedstatedir@
-localstatedir = @localstatedir@
-libdir = @libdir@
-infodir = @infodir@
-mandir = @mandir@
-includedir = @includedir@
-oldincludedir = /usr/include
-
-DESTDIR =
-
-pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
-pkgincludedir = $(includedir)/@PACKAGE@
-
-top_builddir = ..
-
-ACLOCAL = @ACLOCAL@
-AUTOCONF = @AUTOCONF@
-AUTOMAKE = @AUTOMAKE@
-AUTOHEADER = @AUTOHEADER@
-
-INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-transform = @program_transform_name@
-
-NORMAL_INSTALL = :
-PRE_INSTALL = :
-POST_INSTALL = :
-NORMAL_UNINSTALL = :
-PRE_UNINSTALL = :
-POST_UNINSTALL = :
-CC = @CC@
-CFLAGS = @CFLAGS@
-LDFLAGS = @LDFLAGS@
-MAKEINFO = @MAKEINFO@
-MISCFLAGS = @MISCFLAGS@
-PACKAGE = @PACKAGE@
-RANLIB = @RANLIB@
-VERSION = @VERSION@
-
-check_PROGRAMS = reuse tabs tadd tagm tcan_round tcmp tcmp2 tcmp_ui tdiv tdiv_ui tdump teq texp tget_str tlog tconst_log2 tmul tmul_2exp tmul_ui tout_str tconst_pi tpow trandom tround_prec tset_d tset_f tset_q tset_si tset_str tset_z tsqrt tsqrt_ui tui_div tui_sub tswap ttrunc trint tisnan tget_d tatan tcosh tsinh ttanh tacosh tasinh tatanh thyperbolic texp2 tfactorial tsub tasin tconst_euler tcos tsin ttan tsub_ui tset tlog1p texpm1 tlog2 tlog10 tui_pow tpow3 tadd_ui texceptions tfma thypot tacos
-EXTRA_DIST = tgeneric.c
-
-LDADD = $(top_builddir)/libmpfr.a @LDADD@
-INCLUDES = -I$(top_srcdir) @INCLUDES@
-mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
-CONFIG_CLEAN_FILES =
-
-DEFS = @DEFS@ -I. -I$(srcdir)
-CPPFLAGS = @CPPFLAGS@
-LIBS = @LIBS@
-reuse_SOURCES = reuse.c
-reuse_OBJECTS = reuse.o
-reuse_LDADD = $(LDADD)
-reuse_DEPENDENCIES = $(top_builddir)/libmpfr.a
-reuse_LDFLAGS =
-tabs_SOURCES = tabs.c
-tabs_OBJECTS = tabs.o
-tabs_LDADD = $(LDADD)
-tabs_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tabs_LDFLAGS =
-tadd_SOURCES = tadd.c
-tadd_OBJECTS = tadd.o
-tadd_LDADD = $(LDADD)
-tadd_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tadd_LDFLAGS =
-tagm_SOURCES = tagm.c
-tagm_OBJECTS = tagm.o
-tagm_LDADD = $(LDADD)
-tagm_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tagm_LDFLAGS =
-tcan_round_SOURCES = tcan_round.c
-tcan_round_OBJECTS = tcan_round.o
-tcan_round_LDADD = $(LDADD)
-tcan_round_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tcan_round_LDFLAGS =
-tcmp_SOURCES = tcmp.c
-tcmp_OBJECTS = tcmp.o
-tcmp_LDADD = $(LDADD)
-tcmp_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tcmp_LDFLAGS =
-tcmp2_SOURCES = tcmp2.c
-tcmp2_OBJECTS = tcmp2.o
-tcmp2_LDADD = $(LDADD)
-tcmp2_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tcmp2_LDFLAGS =
-tcmp_ui_SOURCES = tcmp_ui.c
-tcmp_ui_OBJECTS = tcmp_ui.o
-tcmp_ui_LDADD = $(LDADD)
-tcmp_ui_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tcmp_ui_LDFLAGS =
-tdiv_SOURCES = tdiv.c
-tdiv_OBJECTS = tdiv.o
-tdiv_LDADD = $(LDADD)
-tdiv_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tdiv_LDFLAGS =
-tdiv_ui_SOURCES = tdiv_ui.c
-tdiv_ui_OBJECTS = tdiv_ui.o
-tdiv_ui_LDADD = $(LDADD)
-tdiv_ui_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tdiv_ui_LDFLAGS =
-tdump_SOURCES = tdump.c
-tdump_OBJECTS = tdump.o
-tdump_LDADD = $(LDADD)
-tdump_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tdump_LDFLAGS =
-teq_SOURCES = teq.c
-teq_OBJECTS = teq.o
-teq_LDADD = $(LDADD)
-teq_DEPENDENCIES = $(top_builddir)/libmpfr.a
-teq_LDFLAGS =
-texp_SOURCES = texp.c
-texp_OBJECTS = texp.o
-texp_LDADD = $(LDADD)
-texp_DEPENDENCIES = $(top_builddir)/libmpfr.a
-texp_LDFLAGS =
-tget_str_SOURCES = tget_str.c
-tget_str_OBJECTS = tget_str.o
-tget_str_LDADD = $(LDADD)
-tget_str_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tget_str_LDFLAGS =
-tlog_SOURCES = tlog.c
-tlog_OBJECTS = tlog.o
-tlog_LDADD = $(LDADD)
-tlog_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tlog_LDFLAGS =
-tconst_log2_SOURCES = tconst_log2.c
-tconst_log2_OBJECTS = tconst_log2.o
-tconst_log2_LDADD = $(LDADD)
-tconst_log2_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tconst_log2_LDFLAGS =
-tmul_SOURCES = tmul.c
-tmul_OBJECTS = tmul.o
-tmul_LDADD = $(LDADD)
-tmul_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tmul_LDFLAGS =
-tmul_2exp_SOURCES = tmul_2exp.c
-tmul_2exp_OBJECTS = tmul_2exp.o
-tmul_2exp_LDADD = $(LDADD)
-tmul_2exp_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tmul_2exp_LDFLAGS =
-tmul_ui_SOURCES = tmul_ui.c
-tmul_ui_OBJECTS = tmul_ui.o
-tmul_ui_LDADD = $(LDADD)
-tmul_ui_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tmul_ui_LDFLAGS =
-tout_str_SOURCES = tout_str.c
-tout_str_OBJECTS = tout_str.o
-tout_str_LDADD = $(LDADD)
-tout_str_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tout_str_LDFLAGS =
-tconst_pi_SOURCES = tconst_pi.c
-tconst_pi_OBJECTS = tconst_pi.o
-tconst_pi_LDADD = $(LDADD)
-tconst_pi_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tconst_pi_LDFLAGS =
-tpow_SOURCES = tpow.c
-tpow_OBJECTS = tpow.o
-tpow_LDADD = $(LDADD)
-tpow_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tpow_LDFLAGS =
-trandom_SOURCES = trandom.c
-trandom_OBJECTS = trandom.o
-trandom_LDADD = $(LDADD)
-trandom_DEPENDENCIES = $(top_builddir)/libmpfr.a
-trandom_LDFLAGS =
-tround_prec_SOURCES = tround_prec.c
-tround_prec_OBJECTS = tround_prec.o
-tround_prec_LDADD = $(LDADD)
-tround_prec_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tround_prec_LDFLAGS =
-tset_d_SOURCES = tset_d.c
-tset_d_OBJECTS = tset_d.o
-tset_d_LDADD = $(LDADD)
-tset_d_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tset_d_LDFLAGS =
-tset_f_SOURCES = tset_f.c
-tset_f_OBJECTS = tset_f.o
-tset_f_LDADD = $(LDADD)
-tset_f_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tset_f_LDFLAGS =
-tset_q_SOURCES = tset_q.c
-tset_q_OBJECTS = tset_q.o
-tset_q_LDADD = $(LDADD)
-tset_q_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tset_q_LDFLAGS =
-tset_si_SOURCES = tset_si.c
-tset_si_OBJECTS = tset_si.o
-tset_si_LDADD = $(LDADD)
-tset_si_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tset_si_LDFLAGS =
-tset_str_SOURCES = tset_str.c
-tset_str_OBJECTS = tset_str.o
-tset_str_LDADD = $(LDADD)
-tset_str_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tset_str_LDFLAGS =
-tset_z_SOURCES = tset_z.c
-tset_z_OBJECTS = tset_z.o
-tset_z_LDADD = $(LDADD)
-tset_z_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tset_z_LDFLAGS =
-tsqrt_SOURCES = tsqrt.c
-tsqrt_OBJECTS = tsqrt.o
-tsqrt_LDADD = $(LDADD)
-tsqrt_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tsqrt_LDFLAGS =
-tsqrt_ui_SOURCES = tsqrt_ui.c
-tsqrt_ui_OBJECTS = tsqrt_ui.o
-tsqrt_ui_LDADD = $(LDADD)
-tsqrt_ui_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tsqrt_ui_LDFLAGS =
-tui_div_SOURCES = tui_div.c
-tui_div_OBJECTS = tui_div.o
-tui_div_LDADD = $(LDADD)
-tui_div_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tui_div_LDFLAGS =
-tui_sub_SOURCES = tui_sub.c
-tui_sub_OBJECTS = tui_sub.o
-tui_sub_LDADD = $(LDADD)
-tui_sub_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tui_sub_LDFLAGS =
-tswap_SOURCES = tswap.c
-tswap_OBJECTS = tswap.o
-tswap_LDADD = $(LDADD)
-tswap_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tswap_LDFLAGS =
-ttrunc_SOURCES = ttrunc.c
-ttrunc_OBJECTS = ttrunc.o
-ttrunc_LDADD = $(LDADD)
-ttrunc_DEPENDENCIES = $(top_builddir)/libmpfr.a
-ttrunc_LDFLAGS =
-trint_SOURCES = trint.c
-trint_OBJECTS = trint.o
-trint_LDADD = $(LDADD)
-trint_DEPENDENCIES = $(top_builddir)/libmpfr.a
-trint_LDFLAGS =
-tisnan_SOURCES = tisnan.c
-tisnan_OBJECTS = tisnan.o
-tisnan_LDADD = $(LDADD)
-tisnan_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tisnan_LDFLAGS =
-tget_d_SOURCES = tget_d.c
-tget_d_OBJECTS = tget_d.o
-tget_d_LDADD = $(LDADD)
-tget_d_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tget_d_LDFLAGS =
-tatan_SOURCES = tatan.c
-tatan_OBJECTS = tatan.o
-tatan_LDADD = $(LDADD)
-tatan_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tatan_LDFLAGS =
-tcosh_SOURCES = tcosh.c
-tcosh_OBJECTS = tcosh.o
-tcosh_LDADD = $(LDADD)
-tcosh_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tcosh_LDFLAGS =
-tsinh_SOURCES = tsinh.c
-tsinh_OBJECTS = tsinh.o
-tsinh_LDADD = $(LDADD)
-tsinh_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tsinh_LDFLAGS =
-ttanh_SOURCES = ttanh.c
-ttanh_OBJECTS = ttanh.o
-ttanh_LDADD = $(LDADD)
-ttanh_DEPENDENCIES = $(top_builddir)/libmpfr.a
-ttanh_LDFLAGS =
-tacosh_SOURCES = tacosh.c
-tacosh_OBJECTS = tacosh.o
-tacosh_LDADD = $(LDADD)
-tacosh_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tacosh_LDFLAGS =
-tasinh_SOURCES = tasinh.c
-tasinh_OBJECTS = tasinh.o
-tasinh_LDADD = $(LDADD)
-tasinh_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tasinh_LDFLAGS =
-tatanh_SOURCES = tatanh.c
-tatanh_OBJECTS = tatanh.o
-tatanh_LDADD = $(LDADD)
-tatanh_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tatanh_LDFLAGS =
-thyperbolic_SOURCES = thyperbolic.c
-thyperbolic_OBJECTS = thyperbolic.o
-thyperbolic_LDADD = $(LDADD)
-thyperbolic_DEPENDENCIES = $(top_builddir)/libmpfr.a
-thyperbolic_LDFLAGS =
-texp2_SOURCES = texp2.c
-texp2_OBJECTS = texp2.o
-texp2_LDADD = $(LDADD)
-texp2_DEPENDENCIES = $(top_builddir)/libmpfr.a
-texp2_LDFLAGS =
-tfactorial_SOURCES = tfactorial.c
-tfactorial_OBJECTS = tfactorial.o
-tfactorial_LDADD = $(LDADD)
-tfactorial_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tfactorial_LDFLAGS =
-tsub_SOURCES = tsub.c
-tsub_OBJECTS = tsub.o
-tsub_LDADD = $(LDADD)
-tsub_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tsub_LDFLAGS =
-tasin_SOURCES = tasin.c
-tasin_OBJECTS = tasin.o
-tasin_LDADD = $(LDADD)
-tasin_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tasin_LDFLAGS =
-tconst_euler_SOURCES = tconst_euler.c
-tconst_euler_OBJECTS = tconst_euler.o
-tconst_euler_LDADD = $(LDADD)
-tconst_euler_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tconst_euler_LDFLAGS =
-tcos_SOURCES = tcos.c
-tcos_OBJECTS = tcos.o
-tcos_LDADD = $(LDADD)
-tcos_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tcos_LDFLAGS =
-tsin_SOURCES = tsin.c
-tsin_OBJECTS = tsin.o
-tsin_LDADD = $(LDADD)
-tsin_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tsin_LDFLAGS =
-ttan_SOURCES = ttan.c
-ttan_OBJECTS = ttan.o
-ttan_LDADD = $(LDADD)
-ttan_DEPENDENCIES = $(top_builddir)/libmpfr.a
-ttan_LDFLAGS =
-tsub_ui_SOURCES = tsub_ui.c
-tsub_ui_OBJECTS = tsub_ui.o
-tsub_ui_LDADD = $(LDADD)
-tsub_ui_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tsub_ui_LDFLAGS =
-tset_SOURCES = tset.c
-tset_OBJECTS = tset.o
-tset_LDADD = $(LDADD)
-tset_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tset_LDFLAGS =
-tlog1p_SOURCES = tlog1p.c
-tlog1p_OBJECTS = tlog1p.o
-tlog1p_LDADD = $(LDADD)
-tlog1p_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tlog1p_LDFLAGS =
-texpm1_SOURCES = texpm1.c
-texpm1_OBJECTS = texpm1.o
-texpm1_LDADD = $(LDADD)
-texpm1_DEPENDENCIES = $(top_builddir)/libmpfr.a
-texpm1_LDFLAGS =
-tlog2_SOURCES = tlog2.c
-tlog2_OBJECTS = tlog2.o
-tlog2_LDADD = $(LDADD)
-tlog2_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tlog2_LDFLAGS =
-tlog10_SOURCES = tlog10.c
-tlog10_OBJECTS = tlog10.o
-tlog10_LDADD = $(LDADD)
-tlog10_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tlog10_LDFLAGS =
-tui_pow_SOURCES = tui_pow.c
-tui_pow_OBJECTS = tui_pow.o
-tui_pow_LDADD = $(LDADD)
-tui_pow_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tui_pow_LDFLAGS =
-tpow3_SOURCES = tpow3.c
-tpow3_OBJECTS = tpow3.o
-tpow3_LDADD = $(LDADD)
-tpow3_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tpow3_LDFLAGS =
-tadd_ui_SOURCES = tadd_ui.c
-tadd_ui_OBJECTS = tadd_ui.o
-tadd_ui_LDADD = $(LDADD)
-tadd_ui_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tadd_ui_LDFLAGS =
-texceptions_SOURCES = texceptions.c
-texceptions_OBJECTS = texceptions.o
-texceptions_LDADD = $(LDADD)
-texceptions_DEPENDENCIES = $(top_builddir)/libmpfr.a
-texceptions_LDFLAGS =
-tfma_SOURCES = tfma.c
-tfma_OBJECTS = tfma.o
-tfma_LDADD = $(LDADD)
-tfma_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tfma_LDFLAGS =
-thypot_SOURCES = thypot.c
-thypot_OBJECTS = thypot.o
-thypot_LDADD = $(LDADD)
-thypot_DEPENDENCIES = $(top_builddir)/libmpfr.a
-thypot_LDFLAGS =
-tacos_SOURCES = tacos.c
-tacos_OBJECTS = tacos.o
-tacos_LDADD = $(LDADD)
-tacos_DEPENDENCIES = $(top_builddir)/libmpfr.a
-tacos_LDFLAGS =
-COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-CCLD = $(CC)
-LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
-DIST_COMMON = Makefile.am Makefile.in
-
-
-DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
-
-TAR = gtar
-GZIP_ENV = --best
-DEP_FILES = .deps/reuse.P .deps/tabs.P .deps/tacos.P .deps/tacosh.P \
-.deps/tadd.P .deps/tadd_ui.P .deps/tagm.P .deps/tasin.P .deps/tasinh.P \
-.deps/tatan.P .deps/tatanh.P .deps/tcan_round.P .deps/tcmp.P \
-.deps/tcmp2.P .deps/tcmp_ui.P .deps/tconst_euler.P .deps/tconst_log2.P \
-.deps/tconst_pi.P .deps/tcos.P .deps/tcosh.P .deps/tdiv.P \
-.deps/tdiv_ui.P .deps/tdump.P .deps/teq.P .deps/texceptions.P \
-.deps/texp.P .deps/texp2.P .deps/texpm1.P .deps/tfactorial.P \
-.deps/tfma.P .deps/tget_d.P .deps/tget_str.P .deps/thyperbolic.P \
-.deps/thypot.P .deps/tisnan.P .deps/tlog.P .deps/tlog10.P \
-.deps/tlog1p.P .deps/tlog2.P .deps/tmul.P .deps/tmul_2exp.P \
-.deps/tmul_ui.P .deps/tout_str.P .deps/tpow.P .deps/tpow3.P \
-.deps/trandom.P .deps/trint.P .deps/tround_prec.P .deps/tset.P \
-.deps/tset_d.P .deps/tset_f.P .deps/tset_q.P .deps/tset_si.P \
-.deps/tset_str.P .deps/tset_z.P .deps/tsin.P .deps/tsinh.P \
-.deps/tsqrt.P .deps/tsqrt_ui.P .deps/tsub.P .deps/tsub_ui.P \
-.deps/tswap.P .deps/ttan.P .deps/ttanh.P .deps/ttrunc.P .deps/tui_div.P \
-.deps/tui_pow.P .deps/tui_sub.P
-SOURCES = reuse.c tabs.c tadd.c tagm.c tcan_round.c tcmp.c tcmp2.c tcmp_ui.c tdiv.c tdiv_ui.c tdump.c teq.c texp.c tget_str.c tlog.c tconst_log2.c tmul.c tmul_2exp.c tmul_ui.c tout_str.c tconst_pi.c tpow.c trandom.c tround_prec.c tset_d.c tset_f.c tset_q.c tset_si.c tset_str.c tset_z.c tsqrt.c tsqrt_ui.c tui_div.c tui_sub.c tswap.c ttrunc.c trint.c tisnan.c tget_d.c tatan.c tcosh.c tsinh.c ttanh.c tacosh.c tasinh.c tatanh.c thyperbolic.c texp2.c tfactorial.c tsub.c tasin.c tconst_euler.c tcos.c tsin.c ttan.c tsub_ui.c tset.c tlog1p.c texpm1.c tlog2.c tlog10.c tui_pow.c tpow3.c tadd_ui.c texceptions.c tfma.c thypot.c tacos.c
-OBJECTS = reuse.o tabs.o tadd.o tagm.o tcan_round.o tcmp.o tcmp2.o tcmp_ui.o tdiv.o tdiv_ui.o tdump.o teq.o texp.o tget_str.o tlog.o tconst_log2.o tmul.o tmul_2exp.o tmul_ui.o tout_str.o tconst_pi.o tpow.o trandom.o tround_prec.o tset_d.o tset_f.o tset_q.o tset_si.o tset_str.o tset_z.o tsqrt.o tsqrt_ui.o tui_div.o tui_sub.o tswap.o ttrunc.o trint.o tisnan.o tget_d.o tatan.o tcosh.o tsinh.o ttanh.o tacosh.o tasinh.o tatanh.o thyperbolic.o texp2.o tfactorial.o tsub.o tasin.o tconst_euler.o tcos.o tsin.o ttan.o tsub_ui.o tset.o tlog1p.o texpm1.o tlog2.o tlog10.o tui_pow.o tpow3.o tadd_ui.o texceptions.o tfma.o thypot.o tacos.o
-
-all: all-redirect
-.SUFFIXES:
-.SUFFIXES: .S .c .o .s
-$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
- cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/Makefile
-
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
- cd $(top_builddir) \
- && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
-
-
-mostlyclean-checkPROGRAMS:
-
-clean-checkPROGRAMS:
- -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS)
-
-distclean-checkPROGRAMS:
-
-maintainer-clean-checkPROGRAMS:
-
-.s.o:
- $(COMPILE) -c $<
-
-.S.o:
- $(COMPILE) -c $<
-
-mostlyclean-compile:
- -rm -f *.o core *.core
-
-clean-compile:
-
-distclean-compile:
- -rm -f *.tab.c
-
-maintainer-clean-compile:
-
-reuse: $(reuse_OBJECTS) $(reuse_DEPENDENCIES)
- @rm -f reuse
- $(LINK) $(reuse_LDFLAGS) $(reuse_OBJECTS) $(reuse_LDADD) $(LIBS)
-
-tabs: $(tabs_OBJECTS) $(tabs_DEPENDENCIES)
- @rm -f tabs
- $(LINK) $(tabs_LDFLAGS) $(tabs_OBJECTS) $(tabs_LDADD) $(LIBS)
-
-tadd: $(tadd_OBJECTS) $(tadd_DEPENDENCIES)
- @rm -f tadd
- $(LINK) $(tadd_LDFLAGS) $(tadd_OBJECTS) $(tadd_LDADD) $(LIBS)
-
-tagm: $(tagm_OBJECTS) $(tagm_DEPENDENCIES)
- @rm -f tagm
- $(LINK) $(tagm_LDFLAGS) $(tagm_OBJECTS) $(tagm_LDADD) $(LIBS)
-
-tcan_round: $(tcan_round_OBJECTS) $(tcan_round_DEPENDENCIES)
- @rm -f tcan_round
- $(LINK) $(tcan_round_LDFLAGS) $(tcan_round_OBJECTS) $(tcan_round_LDADD) $(LIBS)
-
-tcmp: $(tcmp_OBJECTS) $(tcmp_DEPENDENCIES)
- @rm -f tcmp
- $(LINK) $(tcmp_LDFLAGS) $(tcmp_OBJECTS) $(tcmp_LDADD) $(LIBS)
-
-tcmp2: $(tcmp2_OBJECTS) $(tcmp2_DEPENDENCIES)
- @rm -f tcmp2
- $(LINK) $(tcmp2_LDFLAGS) $(tcmp2_OBJECTS) $(tcmp2_LDADD) $(LIBS)
-
-tcmp_ui: $(tcmp_ui_OBJECTS) $(tcmp_ui_DEPENDENCIES)
- @rm -f tcmp_ui
- $(LINK) $(tcmp_ui_LDFLAGS) $(tcmp_ui_OBJECTS) $(tcmp_ui_LDADD) $(LIBS)
-
-tdiv: $(tdiv_OBJECTS) $(tdiv_DEPENDENCIES)
- @rm -f tdiv
- $(LINK) $(tdiv_LDFLAGS) $(tdiv_OBJECTS) $(tdiv_LDADD) $(LIBS)
-
-tdiv_ui: $(tdiv_ui_OBJECTS) $(tdiv_ui_DEPENDENCIES)
- @rm -f tdiv_ui
- $(LINK) $(tdiv_ui_LDFLAGS) $(tdiv_ui_OBJECTS) $(tdiv_ui_LDADD) $(LIBS)
-
-tdump: $(tdump_OBJECTS) $(tdump_DEPENDENCIES)
- @rm -f tdump
- $(LINK) $(tdump_LDFLAGS) $(tdump_OBJECTS) $(tdump_LDADD) $(LIBS)
-
-teq: $(teq_OBJECTS) $(teq_DEPENDENCIES)
- @rm -f teq
- $(LINK) $(teq_LDFLAGS) $(teq_OBJECTS) $(teq_LDADD) $(LIBS)
-
-texp: $(texp_OBJECTS) $(texp_DEPENDENCIES)
- @rm -f texp
- $(LINK) $(texp_LDFLAGS) $(texp_OBJECTS) $(texp_LDADD) $(LIBS)
-
-tget_str: $(tget_str_OBJECTS) $(tget_str_DEPENDENCIES)
- @rm -f tget_str
- $(LINK) $(tget_str_LDFLAGS) $(tget_str_OBJECTS) $(tget_str_LDADD) $(LIBS)
-
-tlog: $(tlog_OBJECTS) $(tlog_DEPENDENCIES)
- @rm -f tlog
- $(LINK) $(tlog_LDFLAGS) $(tlog_OBJECTS) $(tlog_LDADD) $(LIBS)
-
-tconst_log2: $(tconst_log2_OBJECTS) $(tconst_log2_DEPENDENCIES)
- @rm -f tconst_log2
- $(LINK) $(tconst_log2_LDFLAGS) $(tconst_log2_OBJECTS) $(tconst_log2_LDADD) $(LIBS)
-
-tmul: $(tmul_OBJECTS) $(tmul_DEPENDENCIES)
- @rm -f tmul
- $(LINK) $(tmul_LDFLAGS) $(tmul_OBJECTS) $(tmul_LDADD) $(LIBS)
-
-tmul_2exp: $(tmul_2exp_OBJECTS) $(tmul_2exp_DEPENDENCIES)
- @rm -f tmul_2exp
- $(LINK) $(tmul_2exp_LDFLAGS) $(tmul_2exp_OBJECTS) $(tmul_2exp_LDADD) $(LIBS)
-
-tmul_ui: $(tmul_ui_OBJECTS) $(tmul_ui_DEPENDENCIES)
- @rm -f tmul_ui
- $(LINK) $(tmul_ui_LDFLAGS) $(tmul_ui_OBJECTS) $(tmul_ui_LDADD) $(LIBS)
-
-tout_str: $(tout_str_OBJECTS) $(tout_str_DEPENDENCIES)
- @rm -f tout_str
- $(LINK) $(tout_str_LDFLAGS) $(tout_str_OBJECTS) $(tout_str_LDADD) $(LIBS)
-
-tconst_pi: $(tconst_pi_OBJECTS) $(tconst_pi_DEPENDENCIES)
- @rm -f tconst_pi
- $(LINK) $(tconst_pi_LDFLAGS) $(tconst_pi_OBJECTS) $(tconst_pi_LDADD) $(LIBS)
-
-tpow: $(tpow_OBJECTS) $(tpow_DEPENDENCIES)
- @rm -f tpow
- $(LINK) $(tpow_LDFLAGS) $(tpow_OBJECTS) $(tpow_LDADD) $(LIBS)
-
-trandom: $(trandom_OBJECTS) $(trandom_DEPENDENCIES)
- @rm -f trandom
- $(LINK) $(trandom_LDFLAGS) $(trandom_OBJECTS) $(trandom_LDADD) $(LIBS)
-
-tround_prec: $(tround_prec_OBJECTS) $(tround_prec_DEPENDENCIES)
- @rm -f tround_prec
- $(LINK) $(tround_prec_LDFLAGS) $(tround_prec_OBJECTS) $(tround_prec_LDADD) $(LIBS)
-
-tset_d: $(tset_d_OBJECTS) $(tset_d_DEPENDENCIES)
- @rm -f tset_d
- $(LINK) $(tset_d_LDFLAGS) $(tset_d_OBJECTS) $(tset_d_LDADD) $(LIBS)
-
-tset_f: $(tset_f_OBJECTS) $(tset_f_DEPENDENCIES)
- @rm -f tset_f
- $(LINK) $(tset_f_LDFLAGS) $(tset_f_OBJECTS) $(tset_f_LDADD) $(LIBS)
-
-tset_q: $(tset_q_OBJECTS) $(tset_q_DEPENDENCIES)
- @rm -f tset_q
- $(LINK) $(tset_q_LDFLAGS) $(tset_q_OBJECTS) $(tset_q_LDADD) $(LIBS)
-
-tset_si: $(tset_si_OBJECTS) $(tset_si_DEPENDENCIES)
- @rm -f tset_si
- $(LINK) $(tset_si_LDFLAGS) $(tset_si_OBJECTS) $(tset_si_LDADD) $(LIBS)
-
-tset_str: $(tset_str_OBJECTS) $(tset_str_DEPENDENCIES)
- @rm -f tset_str
- $(LINK) $(tset_str_LDFLAGS) $(tset_str_OBJECTS) $(tset_str_LDADD) $(LIBS)
-
-tset_z: $(tset_z_OBJECTS) $(tset_z_DEPENDENCIES)
- @rm -f tset_z
- $(LINK) $(tset_z_LDFLAGS) $(tset_z_OBJECTS) $(tset_z_LDADD) $(LIBS)
-
-tsqrt: $(tsqrt_OBJECTS) $(tsqrt_DEPENDENCIES)
- @rm -f tsqrt
- $(LINK) $(tsqrt_LDFLAGS) $(tsqrt_OBJECTS) $(tsqrt_LDADD) $(LIBS)
-
-tsqrt_ui: $(tsqrt_ui_OBJECTS) $(tsqrt_ui_DEPENDENCIES)
- @rm -f tsqrt_ui
- $(LINK) $(tsqrt_ui_LDFLAGS) $(tsqrt_ui_OBJECTS) $(tsqrt_ui_LDADD) $(LIBS)
-
-tui_div: $(tui_div_OBJECTS) $(tui_div_DEPENDENCIES)
- @rm -f tui_div
- $(LINK) $(tui_div_LDFLAGS) $(tui_div_OBJECTS) $(tui_div_LDADD) $(LIBS)
-
-tui_sub: $(tui_sub_OBJECTS) $(tui_sub_DEPENDENCIES)
- @rm -f tui_sub
- $(LINK) $(tui_sub_LDFLAGS) $(tui_sub_OBJECTS) $(tui_sub_LDADD) $(LIBS)
-
-tswap: $(tswap_OBJECTS) $(tswap_DEPENDENCIES)
- @rm -f tswap
- $(LINK) $(tswap_LDFLAGS) $(tswap_OBJECTS) $(tswap_LDADD) $(LIBS)
-
-ttrunc: $(ttrunc_OBJECTS) $(ttrunc_DEPENDENCIES)
- @rm -f ttrunc
- $(LINK) $(ttrunc_LDFLAGS) $(ttrunc_OBJECTS) $(ttrunc_LDADD) $(LIBS)
-
-trint: $(trint_OBJECTS) $(trint_DEPENDENCIES)
- @rm -f trint
- $(LINK) $(trint_LDFLAGS) $(trint_OBJECTS) $(trint_LDADD) $(LIBS)
-
-tisnan: $(tisnan_OBJECTS) $(tisnan_DEPENDENCIES)
- @rm -f tisnan
- $(LINK) $(tisnan_LDFLAGS) $(tisnan_OBJECTS) $(tisnan_LDADD) $(LIBS)
-
-tget_d: $(tget_d_OBJECTS) $(tget_d_DEPENDENCIES)
- @rm -f tget_d
- $(LINK) $(tget_d_LDFLAGS) $(tget_d_OBJECTS) $(tget_d_LDADD) $(LIBS)
-
-tatan: $(tatan_OBJECTS) $(tatan_DEPENDENCIES)
- @rm -f tatan
- $(LINK) $(tatan_LDFLAGS) $(tatan_OBJECTS) $(tatan_LDADD) $(LIBS)
-
-tcosh: $(tcosh_OBJECTS) $(tcosh_DEPENDENCIES)
- @rm -f tcosh
- $(LINK) $(tcosh_LDFLAGS) $(tcosh_OBJECTS) $(tcosh_LDADD) $(LIBS)
-
-tsinh: $(tsinh_OBJECTS) $(tsinh_DEPENDENCIES)
- @rm -f tsinh
- $(LINK) $(tsinh_LDFLAGS) $(tsinh_OBJECTS) $(tsinh_LDADD) $(LIBS)
-
-ttanh: $(ttanh_OBJECTS) $(ttanh_DEPENDENCIES)
- @rm -f ttanh
- $(LINK) $(ttanh_LDFLAGS) $(ttanh_OBJECTS) $(ttanh_LDADD) $(LIBS)
-
-tacosh: $(tacosh_OBJECTS) $(tacosh_DEPENDENCIES)
- @rm -f tacosh
- $(LINK) $(tacosh_LDFLAGS) $(tacosh_OBJECTS) $(tacosh_LDADD) $(LIBS)
-
-tasinh: $(tasinh_OBJECTS) $(tasinh_DEPENDENCIES)
- @rm -f tasinh
- $(LINK) $(tasinh_LDFLAGS) $(tasinh_OBJECTS) $(tasinh_LDADD) $(LIBS)
-
-tatanh: $(tatanh_OBJECTS) $(tatanh_DEPENDENCIES)
- @rm -f tatanh
- $(LINK) $(tatanh_LDFLAGS) $(tatanh_OBJECTS) $(tatanh_LDADD) $(LIBS)
-
-thyperbolic: $(thyperbolic_OBJECTS) $(thyperbolic_DEPENDENCIES)
- @rm -f thyperbolic
- $(LINK) $(thyperbolic_LDFLAGS) $(thyperbolic_OBJECTS) $(thyperbolic_LDADD) $(LIBS)
-
-texp2: $(texp2_OBJECTS) $(texp2_DEPENDENCIES)
- @rm -f texp2
- $(LINK) $(texp2_LDFLAGS) $(texp2_OBJECTS) $(texp2_LDADD) $(LIBS)
-
-tfactorial: $(tfactorial_OBJECTS) $(tfactorial_DEPENDENCIES)
- @rm -f tfactorial
- $(LINK) $(tfactorial_LDFLAGS) $(tfactorial_OBJECTS) $(tfactorial_LDADD) $(LIBS)
-
-tsub: $(tsub_OBJECTS) $(tsub_DEPENDENCIES)
- @rm -f tsub
- $(LINK) $(tsub_LDFLAGS) $(tsub_OBJECTS) $(tsub_LDADD) $(LIBS)
-
-tasin: $(tasin_OBJECTS) $(tasin_DEPENDENCIES)
- @rm -f tasin
- $(LINK) $(tasin_LDFLAGS) $(tasin_OBJECTS) $(tasin_LDADD) $(LIBS)
-
-tconst_euler: $(tconst_euler_OBJECTS) $(tconst_euler_DEPENDENCIES)
- @rm -f tconst_euler
- $(LINK) $(tconst_euler_LDFLAGS) $(tconst_euler_OBJECTS) $(tconst_euler_LDADD) $(LIBS)
-
-tcos: $(tcos_OBJECTS) $(tcos_DEPENDENCIES)
- @rm -f tcos
- $(LINK) $(tcos_LDFLAGS) $(tcos_OBJECTS) $(tcos_LDADD) $(LIBS)
-
-tsin: $(tsin_OBJECTS) $(tsin_DEPENDENCIES)
- @rm -f tsin
- $(LINK) $(tsin_LDFLAGS) $(tsin_OBJECTS) $(tsin_LDADD) $(LIBS)
-
-ttan: $(ttan_OBJECTS) $(ttan_DEPENDENCIES)
- @rm -f ttan
- $(LINK) $(ttan_LDFLAGS) $(ttan_OBJECTS) $(ttan_LDADD) $(LIBS)
-
-tsub_ui: $(tsub_ui_OBJECTS) $(tsub_ui_DEPENDENCIES)
- @rm -f tsub_ui
- $(LINK) $(tsub_ui_LDFLAGS) $(tsub_ui_OBJECTS) $(tsub_ui_LDADD) $(LIBS)
-
-tset: $(tset_OBJECTS) $(tset_DEPENDENCIES)
- @rm -f tset
- $(LINK) $(tset_LDFLAGS) $(tset_OBJECTS) $(tset_LDADD) $(LIBS)
-
-tlog1p: $(tlog1p_OBJECTS) $(tlog1p_DEPENDENCIES)
- @rm -f tlog1p
- $(LINK) $(tlog1p_LDFLAGS) $(tlog1p_OBJECTS) $(tlog1p_LDADD) $(LIBS)
-
-texpm1: $(texpm1_OBJECTS) $(texpm1_DEPENDENCIES)
- @rm -f texpm1
- $(LINK) $(texpm1_LDFLAGS) $(texpm1_OBJECTS) $(texpm1_LDADD) $(LIBS)
-
-tlog2: $(tlog2_OBJECTS) $(tlog2_DEPENDENCIES)
- @rm -f tlog2
- $(LINK) $(tlog2_LDFLAGS) $(tlog2_OBJECTS) $(tlog2_LDADD) $(LIBS)
-
-tlog10: $(tlog10_OBJECTS) $(tlog10_DEPENDENCIES)
- @rm -f tlog10
- $(LINK) $(tlog10_LDFLAGS) $(tlog10_OBJECTS) $(tlog10_LDADD) $(LIBS)
-
-tui_pow: $(tui_pow_OBJECTS) $(tui_pow_DEPENDENCIES)
- @rm -f tui_pow
- $(LINK) $(tui_pow_LDFLAGS) $(tui_pow_OBJECTS) $(tui_pow_LDADD) $(LIBS)
-
-tpow3: $(tpow3_OBJECTS) $(tpow3_DEPENDENCIES)
- @rm -f tpow3
- $(LINK) $(tpow3_LDFLAGS) $(tpow3_OBJECTS) $(tpow3_LDADD) $(LIBS)
-
-tadd_ui: $(tadd_ui_OBJECTS) $(tadd_ui_DEPENDENCIES)
- @rm -f tadd_ui
- $(LINK) $(tadd_ui_LDFLAGS) $(tadd_ui_OBJECTS) $(tadd_ui_LDADD) $(LIBS)
-
-texceptions: $(texceptions_OBJECTS) $(texceptions_DEPENDENCIES)
- @rm -f texceptions
- $(LINK) $(texceptions_LDFLAGS) $(texceptions_OBJECTS) $(texceptions_LDADD) $(LIBS)
-
-tfma: $(tfma_OBJECTS) $(tfma_DEPENDENCIES)
- @rm -f tfma
- $(LINK) $(tfma_LDFLAGS) $(tfma_OBJECTS) $(tfma_LDADD) $(LIBS)
-
-thypot: $(thypot_OBJECTS) $(thypot_DEPENDENCIES)
- @rm -f thypot
- $(LINK) $(thypot_LDFLAGS) $(thypot_OBJECTS) $(thypot_LDADD) $(LIBS)
-
-tacos: $(tacos_OBJECTS) $(tacos_DEPENDENCIES)
- @rm -f tacos
- $(LINK) $(tacos_LDFLAGS) $(tacos_OBJECTS) $(tacos_LDADD) $(LIBS)
-
-tags: TAGS
-
-ID: $(HEADERS) $(SOURCES) $(LISP)
- list='$(SOURCES) $(HEADERS)'; \
- unique=`for i in $$list; do echo $$i; done | \
- awk ' { files[$$0] = 1; } \
- END { for (i in files) print i; }'`; \
- here=`pwd` && cd $(srcdir) \
- && mkid -f$$here/ID $$unique $(LISP)
-
-TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
- tags=; \
- here=`pwd`; \
- list='$(SOURCES) $(HEADERS)'; \
- unique=`for i in $$list; do echo $$i; done | \
- awk ' { files[$$0] = 1; } \
- END { for (i in files) print i; }'`; \
- test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
- || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
-
-mostlyclean-tags:
-
-clean-tags:
-
-distclean-tags:
- -rm -f TAGS ID
-
-maintainer-clean-tags:
-
-distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
-
-subdir = tests
-
-distdir: $(DISTFILES)
- here=`cd $(top_builddir) && pwd`; \
- top_distdir=`cd $(top_distdir) && pwd`; \
- distdir=`cd $(distdir) && pwd`; \
- cd $(top_srcdir) \
- && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu tests/Makefile
- @for file in $(DISTFILES); do \
- d=$(srcdir); \
- if test -d $$d/$$file; then \
- cp -pr $$d/$$file $(distdir)/$$file; \
- else \
- test -f $(distdir)/$$file \
- || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
- || cp -p $$d/$$file $(distdir)/$$file || :; \
- fi; \
- done
-
-DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
-
--include $(DEP_FILES)
-
-mostlyclean-depend:
-
-clean-depend:
-
-distclean-depend:
- -rm -rf .deps
-
-maintainer-clean-depend:
-
-%.o: %.c
- @echo '$(COMPILE) -c $<'; \
- $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
- @-cp .deps/$(*F).pp .deps/$(*F).P; \
- tr ' ' '\012' < .deps/$(*F).pp \
- | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
- >> .deps/$(*F).P; \
- rm .deps/$(*F).pp
-
-%.lo: %.c
- @echo '$(LTCOMPILE) -c $<'; \
- $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
- @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
- < .deps/$(*F).pp > .deps/$(*F).P; \
- tr ' ' '\012' < .deps/$(*F).pp \
- | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
- >> .deps/$(*F).P; \
- rm -f .deps/$(*F).pp
-info-am:
-info: info-am
-dvi-am:
-dvi: dvi-am
-check-am: all-am
- $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
-check: check-am
-installcheck-am:
-installcheck: installcheck-am
-install-exec-am:
-install-exec: install-exec-am
-
-install-data-am:
-install-data: install-data-am
-
-install-am: all-am
- @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-install: install-am
-uninstall-am:
-uninstall: uninstall-am
-all-am: Makefile
-all-redirect: all-am
-install-strip:
- $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
-installdirs:
-
-
-mostlyclean-generic:
-
-clean-generic:
-
-distclean-generic:
- -rm -f Makefile $(CONFIG_CLEAN_FILES)
- -rm -f config.cache config.log stamp-h stamp-h[0-9]*
-
-maintainer-clean-generic:
-mostlyclean-am: mostlyclean-checkPROGRAMS mostlyclean-compile \
- mostlyclean-tags mostlyclean-depend mostlyclean-generic
-
-mostlyclean: mostlyclean-am
-
-clean-am: clean-checkPROGRAMS clean-compile clean-tags clean-depend \
- clean-generic mostlyclean-am
-
-clean: clean-am
-
-distclean-am: distclean-checkPROGRAMS distclean-compile distclean-tags \
- distclean-depend distclean-generic clean-am
-
-distclean: distclean-am
-
-maintainer-clean-am: maintainer-clean-checkPROGRAMS \
- maintainer-clean-compile maintainer-clean-tags \
- maintainer-clean-depend maintainer-clean-generic \
- distclean-am
- @echo "This command is intended for maintainers to use;"
- @echo "it deletes files that may require special tools to rebuild."
-
-maintainer-clean: maintainer-clean-am
-
-.PHONY: mostlyclean-checkPROGRAMS distclean-checkPROGRAMS \
-clean-checkPROGRAMS maintainer-clean-checkPROGRAMS mostlyclean-compile \
-distclean-compile clean-compile maintainer-clean-compile tags \
-mostlyclean-tags distclean-tags clean-tags maintainer-clean-tags \
-distdir mostlyclean-depend distclean-depend clean-depend \
-maintainer-clean-depend info-am info dvi-am dvi check check-am \
-installcheck-am installcheck install-exec-am install-exec \
-install-data-am install-data install-am install uninstall-am uninstall \
-all-redirect all-am all installdirs mostlyclean-generic \
-distclean-generic clean-generic maintainer-clean-generic clean \
-mostlyclean distclean maintainer-clean
-
-
-../libmpfr.a:
- cd $(top_srcdir); make libmpfr.a
-
-check: all
- for i in $(check_PROGRAMS); do echo Testing $$i ; ./$$i || echo "### $$i failed ###"; done
-
-# Tell versions [3.59,3.63) of GNU make to not export all variables.
-# Otherwise a system limit (for SysV at least) may be exceeded.
-.NOEXPORT:
diff --git a/tests/mpf_compat.h b/tests/mpf_compat.h
index 04f047efd..07ddfcf33 100644
--- a/tests/mpf_compat.h
+++ b/tests/mpf_compat.h
@@ -1,6 +1,6 @@
/* Test compatibility mpf-mpfr.
-Copyright 2003 Free Software Foundation.
+Copyright 2003, 2004 Free Software Foundation.
This file is part of the MPFR Library.
@@ -160,19 +160,28 @@ main ()
/* Input and Output Functions */
f = fopen ("/dev/null", "w");
- mpf_out_str (f, 10, 10, x);
- fclose (f);
+ if (f != NULL)
+ {
+ mpf_out_str (f, 10, 10, x);
+ fclose (f);
+ }
mpf_set_prec (x, 15);
mpf_set_prec (y, 15);
+ /* We may use src_fopen instead of fopen, but it is defined
+ in mpfr-test, and not in mpfr.h and gmp.h, and we want
+ to test theses includes files. */
f = fopen ("inp_str.data", "r");
- i = mpf_inp_str (x, f, 10);
- if ((i == 0) || mpf_cmp_ui (x, 31415))
+ if (f != NULL)
{
- printf ("Error in reading 1st line from file inp_str.data\n");
- exit (1);
+ i = mpf_inp_str (x, f, 10);
+ if ((i == 0) || mpf_cmp_ui (x, 31415))
+ {
+ printf ("Error in reading 1st line from file inp_str.data\n");
+ exit (1);
+ }
+ fclose (f);
}
- fclose (f);
/* Miscellaneous Functions */
diff --git a/tests/tabs.c b/tests/tabs.c
index ba65061b3..70a5400d8 100644
--- a/tests/tabs.c
+++ b/tests/tabs.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_abs.
-Copyright 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+Copyright 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -30,7 +30,7 @@ check_inexact (void)
{
mp_prec_t p, q;
mpfr_t x, y, absx;
- mp_rnd_t rnd;
+ int rnd;
int inexact, cmp;
mpfr_init (x);
@@ -54,7 +54,7 @@ check_inexact (void)
mpfr_set_prec (y, q);
for (rnd = 0; rnd < GMP_RND_MAX; rnd++)
{
- inexact = mpfr_abs (y, x, rnd);
+ inexact = mpfr_abs (y, x, (mp_rnd_t) rnd);
cmp = mpfr_cmp (y, absx);
if (((inexact == 0) && (cmp != 0)) ||
((inexact > 0) && (cmp <= 0)) ||
@@ -138,7 +138,7 @@ check_cmp(int argc, char *argv[])
mpfr_random(x);
MPFR_SET_SIGN(x, sign);
rnd = RND_RAND();
- mpfr_abs(y, x, rnd);
+ mpfr_abs(y, x, (mp_rnd_t) rnd);
MPFR_SET_POS(x);
if (mpfr_cmp(x,y))
{
diff --git a/tests/tacos.c b/tests/tacos.c
index e1df1cb9b..14c20efb9 100644
--- a/tests/tacos.c
+++ b/tests/tacos.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_acos.
-Copyright 2001, 2002, 2003, 2004 Free Software Foundation.
+Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation.
Contributed by Mathieu Dutour.
This file is part of the MPFR Library.
@@ -75,8 +75,8 @@ special_overflow (void)
{
mpfr_t x, y;
- mpfr_set_emin (-125);
- mpfr_set_emax (128);
+ set_emin (-125);
+ set_emax (128);
mpfr_init2 (x, 24);
mpfr_init2 (y, 48);
mpfr_set_str_binary (x, "0.101100100000000000110100E0");
@@ -90,15 +90,15 @@ special_overflow (void)
}
mpfr_clear (y);
mpfr_clear (x);
- mpfr_set_emin (MPFR_EMIN_MIN);
- mpfr_set_emax (MPFR_EMAX_MAX);
+ set_emin (MPFR_EMIN_MIN);
+ set_emax (MPFR_EMAX_MAX);
}
int
main (void)
{
mpfr_t x, y;
- mp_rnd_t r;
+ int r;
tests_start_mpfr ();
@@ -145,13 +145,13 @@ main (void)
for (r = 0; r < GMP_RND_MAX; r++)
{
mpfr_set_ui (x, 0, GMP_RNDN); /* exact */
- mpfr_acos (y, x, r);
- mpfr_const_pi (x, r);
+ mpfr_acos (y, x, (mp_rnd_t) r);
+ mpfr_const_pi (x, (mp_rnd_t) r);
mpfr_div_2exp (x, x, 1, GMP_RNDN); /* exact */
if (mpfr_cmp (x, y))
{
printf ("Error: acos(0) != Pi/2 for rnd=%s\n",
- mpfr_print_rnd_mode (r));
+ mpfr_print_rnd_mode ((mp_rnd_t) r));
exit (1);
}
}
@@ -160,12 +160,12 @@ main (void)
for (r = 0; r < GMP_RND_MAX; r++)
{
mpfr_set_si (x, -1, GMP_RNDN); /* exact */
- mpfr_acos (y, x, r);
- mpfr_const_pi (x, r);
+ mpfr_acos (y, x, (mp_rnd_t) r);
+ mpfr_const_pi (x, (mp_rnd_t) r);
if (mpfr_cmp (x, y))
{
printf ("Error: acos(1) != Pi for rnd=%s\n",
- mpfr_print_rnd_mode (r));
+ mpfr_print_rnd_mode ((mp_rnd_t) r));
exit (1);
}
}
diff --git a/tests/tadd.c b/tests/tadd.c
index 1b908095d..161ad9b64 100644
--- a/tests/tadd.c
+++ b/tests/tadd.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_add and mpfr_sub.
-Copyright 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation.
+Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation.
This file is part of the MPFR Library.
@@ -509,7 +509,7 @@ check_inexact (void)
abs(EXP(x)-EXP(u)) + max(prec(x), prec(u)) + 1 */
pz = pz + MAX(MPFR_PREC(x), MPFR_PREC(u)) + 1;
mpfr_set_prec (z, pz);
- rnd = RND_RAND();
+ rnd = (mp_rnd_t) RND_RAND();
if (test_add (z, x, u, rnd))
{
printf ("z <- x + u should be exact\n");
@@ -519,7 +519,7 @@ check_inexact (void)
exit (1);
}
{
- rnd = RND_RAND();
+ rnd = (mp_rnd_t) RND_RAND();
inexact = test_add (y, x, u, rnd);
cmp = mpfr_cmp (y, z);
if (((inexact == 0) && (cmp != 0)) ||
@@ -614,7 +614,7 @@ check_overflow (void)
{
mpfr_t a, b, c;
mp_prec_t prec_a;
- mp_rnd_t r;
+ int r;
mpfr_init2 (a, 256);
mpfr_init2 (b, 256);
@@ -629,7 +629,7 @@ check_overflow (void)
{
mpfr_set_prec (a, prec_a);
mpfr_clear_overflow ();
- test_add (a, b, c, r);
+ test_add (a, b, c, (mp_rnd_t) r);
if (!mpfr_overflow_p ())
{
printf ("No overflow in check_overflow\n");
@@ -695,7 +695,7 @@ check_1111 (void)
mpfr_add (c, c, one, GMP_RNDN);
diff = (randlimb () % (2*m)) - m;
mpfr_mul_2si (c, c, diff, GMP_RNDN);
- rnd_mode = RND_RAND ();
+ rnd_mode = (mp_rnd_t) RND_RAND ();
inex_a = test_add (a, b, c, rnd_mode);
mpfr_init2 (s, MPFR_PREC_MIN + 2*m);
inex_s = mpfr_add (s, b, c, GMP_RNDN); /* exact */
@@ -740,15 +740,15 @@ check_1minuseps (void)
0, 1, 2, 3, 4, 29, 30, 31, 32, 33, 34, 35, 61, 62, 63, 64, 65, 66, 67
};
mpfr_t a, b, c;
- int ia, ib, ic;
+ unsigned int ia, ib, ic;
mpfr_init2 (c, MPFR_PREC_MIN);
- for (ia = 0; ia < numberof(prec_a); ia++)
+ for (ia = 0; ia < numberof (prec_a); ia++)
for (ib = 0; ib < numberof(supp_b); ib++)
{
mp_prec_t prec_b;
- mp_rnd_t rnd_mode;
+ int rnd_mode;
prec_b = prec_a[ia] + supp_b[ib];
@@ -767,23 +767,23 @@ check_1minuseps (void)
mpfr_set_ui (c, 1, GMP_RNDN);
mpfr_div_ui (c, c, prec_a[ia] + supp_b[ic], GMP_RNDN);
- inex_a = test_add (a, b, c, rnd_mode);
+ inex_a = test_add (a, b, c, (mp_rnd_t) rnd_mode);
mpfr_init2 (s, 256);
inex_s = mpfr_add (s, b, c, GMP_RNDN); /* exact */
if (inex_s)
{
printf ("check_1minuseps: result should have been exact "
- "(ia = %d, ib = %d, ic = %d)\n", ia, ib, ic);
+ "(ia = %u, ib = %u, ic = %u)\n", ia, ib, ic);
exit (1);
}
- inex_s = mpfr_prec_round (s, prec_a[ia], rnd_mode);
+ inex_s = mpfr_prec_round (s, prec_a[ia], (mp_rnd_t) rnd_mode);
if ((inex_a < 0 && inex_s >= 0) ||
(inex_a == 0 && inex_s != 0) ||
(inex_a > 0 && inex_s <= 0) ||
!mpfr_equal_p (a, s))
{
printf ("check_1minuseps: results are different.\n");
- printf ("ia = %d, ib = %d, ic = %d\n", ia, ib, ic);
+ printf ("ia = %u, ib = %u, ic = %u\n", ia, ib, ic);
exit (1);
}
mpfr_clear (s);
diff --git a/tests/tadd1sp.c b/tests/tadd1sp.c
index 804e700d3..52a7f9bc2 100644
--- a/tests/tadd1sp.c
+++ b/tests/tadd1sp.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_add1sp.
-Copyright 2004 Free Software Foundation.
+Copyright 2004, 2005 Free Software Foundation.
This file is part of the MPFR Library.
@@ -32,11 +32,11 @@ check_overflow (void)
{
mpfr_t x, y, z1, z2;
- mpfr_set_emin (-1021);
- mpfr_set_emax (1024);
+ set_emin (-1021);
+ set_emax (1024);
mpfr_inits (x, y, z1, z2, NULL);
-
+
mpfr_set_str1 (x, "8.00468257869324898448e+307");
mpfr_set_str1 (y, "7.44784712422708645156e+307");
mpfr_add1sp (z1, x, y, GMP_RNDN);
@@ -67,7 +67,7 @@ int main(void)
#define STD_ERROR \
{\
printf("ERROR: for %s and p=%lu and i=%d:\nB=",\
- mpfr_print_rnd_mode(r), p, i);\
+ mpfr_print_rnd_mode ((mp_rnd_t) r), p, i);\
mpfr_print_binary(b);\
printf("\nC="); mpfr_print_binary(c);\
printf("\nadd1 : "); mpfr_print_binary(a1);\
@@ -79,49 +79,50 @@ int main(void)
#define STD_ERROR2 \
{\
printf("ERROR: Wrong inexact flag for %s and p=%lu and i=%d:\nB=",\
- mpfr_print_rnd_mode(r), p, i);\
+ mpfr_print_rnd_mode ((mp_rnd_t) r), p, i);\
mpfr_print_binary(b);\
printf("\nC="); mpfr_print_binary(c);\
printf("\nA="); mpfr_print_binary(a1);\
printf("\nAdd1: %d. Add1sp: %d\n", \
- inexact1, inexact2); \
+ inexact1, inexact2); \
exit(1);\
}
#define SET_PREC(_p) \
- { p = _p; \
- mpfr_set_prec(a1, _p); mpfr_set_prec(a2, _p); \
- mpfr_set_prec(b, _p); mpfr_set_prec(c, _p); \
- }
+ { \
+ p = _p; \
+ mpfr_set_prec(a1, _p); mpfr_set_prec(a2, _p); \
+ mpfr_set_prec(b, _p); mpfr_set_prec(c, _p); \
+ }
void check_random(mp_prec_t p)
{
mpfr_t a1,b,c,a2;
- mp_rnd_t r;
+ int r;
int i, inexact1, inexact2;
mpfr_inits2(p, a1,b,c,a2, NULL);
- for(i = 0 ; i < 500 ; i++)
+ for (i = 0 ; i < 500 ; i++)
{
mpfr_random(b);
mpfr_random(c);
if (MPFR_IS_PURE_FP(b) && MPFR_IS_PURE_FP(c))
- {
- if (MPFR_GET_EXP(b) < MPFR_GET_EXP(c))
- mpfr_swap(b, c);
- if (MPFR_IS_PURE_FP(b) && MPFR_IS_PURE_FP(c))
- for(r = 0 ; r < GMP_RND_MAX ; r++)
- {
- inexact1 = mpfr_add1(a1, b, c, r);
- inexact2 = mpfr_add1sp(a2, b, c, r);
- if (mpfr_cmp(a1, a2))
- STD_ERROR;
- if (inexact1 != inexact2)
- STD_ERROR2;
- }
- }
+ {
+ if (MPFR_GET_EXP(b) < MPFR_GET_EXP(c))
+ mpfr_swap(b, c);
+ if (MPFR_IS_PURE_FP(b) && MPFR_IS_PURE_FP(c))
+ for (r = 0 ; r < GMP_RND_MAX ; r++)
+ {
+ inexact1 = mpfr_add1(a1, b, c, (mp_rnd_t) r);
+ inexact2 = mpfr_add1sp(a2, b, c, (mp_rnd_t) r);
+ if (mpfr_cmp(a1, a2))
+ STD_ERROR;
+ if (inexact1 != inexact2)
+ STD_ERROR2;
+ }
+ }
}
mpfr_clears(a1,a2,b,c,NULL);
@@ -130,32 +131,32 @@ void check_random(mp_prec_t p)
void check_special(void)
{
mpfr_t a1,a2,b,c;
- mp_rnd_t r;
+ int r;
mpfr_prec_t p;
int i = -1, inexact1, inexact2;
mpfr_inits(a1,a2,b,c,NULL);
- for(r = 0 ; r < GMP_RND_MAX ; r++)
+ for (r = 0 ; r < GMP_RND_MAX ; r++)
{
SET_PREC(53);
mpfr_set_str1 (b, "1@100");
mpfr_set_str1 (c, "1@1");
- inexact1 = mpfr_add1(a1, b, c, r);
- inexact2 = mpfr_add1sp(a2, b, c, r);
+ inexact1 = mpfr_add1(a1, b, c, (mp_rnd_t) r);
+ inexact2 = mpfr_add1sp(a2, b, c, (mp_rnd_t) r);
if (mpfr_cmp(a1, a2))
- STD_ERROR;
+ STD_ERROR;
if (inexact1 != inexact2)
- STD_ERROR2;
+ STD_ERROR2;
mpfr_set_str_binary (b, "1E53");
mpfr_set_str_binary (c, "1E0");
- inexact1 = mpfr_add1(a1, b, c, r);
- inexact2 = mpfr_add1sp(a2, b, c, r);
+ inexact1 = mpfr_add1(a1, b, c, (mp_rnd_t) r);
+ inexact2 = mpfr_add1sp(a2, b, c, (mp_rnd_t) r);
if (mpfr_cmp(a1, a2))
STD_ERROR;
if (inexact1 != inexact2)
STD_ERROR2;
}
- mpfr_clears(a1,a2,b,c,NULL);
+ mpfr_clears(a1,a2,b,c,NULL);
}
diff --git a/tests/tadd_ui.c b/tests/tadd_ui.c
index 059755669..e7ae1c4d9 100644
--- a/tests/tadd_ui.c
+++ b/tests/tadd_ui.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_add_ui
-Copyright 2000, 2001, 2002, 2003, 2004 Free Software Foundation.
+Copyright 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation.
This file is part of the MPFR Library.
@@ -27,7 +27,7 @@ MA 02111-1307, USA. */
/* checks that x+y gives the right results with 53 bits of precision */
static void
-check3 (const char *xs, unsigned long y, unsigned int rnd_mode, const char *zs)
+check3 (const char *xs, unsigned long y, mp_rnd_t rnd_mode, const char *zs)
{
mpfr_t xx, zz;
diff --git a/tests/tasin.c b/tests/tasin.c
index 12bdaf579..57e3d7e21 100644
--- a/tests/tasin.c
+++ b/tests/tasin.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_asin.
-Copyright 2001, 2002, 2003, 2004 Free Software Foundation.
+Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation.
Original version by Mathieu Dutour.
This file is part of the MPFR Library.
@@ -32,7 +32,7 @@ static void
special (void)
{
mpfr_t x, y;
- mp_rnd_t r;
+ int r;
mpfr_init (x);
mpfr_init (y);
@@ -98,13 +98,13 @@ special (void)
for (r = 0; r < GMP_RND_MAX; r++)
{
mpfr_set_ui (x, 1, GMP_RNDN); /* exact */
- mpfr_asin (y, x, r);
- mpfr_const_pi (x, r);
+ mpfr_asin (y, x, (mp_rnd_t) r);
+ mpfr_const_pi (x, (mp_rnd_t) r);
mpfr_div_2exp (x, x, 1, GMP_RNDN); /* exact */
if (mpfr_cmp (x, y))
{
printf ("Error: asin(1) != Pi/2 for rnd=%s\n",
- mpfr_print_rnd_mode (r));
+ mpfr_print_rnd_mode ((mp_rnd_t) r));
exit (1);
}
}
@@ -113,14 +113,14 @@ special (void)
for (r = 0; r < GMP_RND_MAX; r++)
{
mpfr_set_si (x, -1, GMP_RNDN); /* exact */
- mpfr_asin (y, x, r);
- mpfr_const_pi (x, MPFR_INVERT_RND(r));
+ mpfr_asin (y, x, (mp_rnd_t) r);
+ mpfr_const_pi (x, MPFR_INVERT_RND((mp_rnd_t) r));
mpfr_neg (x, x, GMP_RNDN); /* exact */
mpfr_div_2exp (x, x, 1, GMP_RNDN); /* exact */
if (mpfr_cmp (x, y))
{
printf ("Error: asin(-1) != -Pi/2 for rnd=%s\n",
- mpfr_print_rnd_mode (r));
+ mpfr_print_rnd_mode ((mp_rnd_t) r));
exit (1);
}
}
@@ -157,8 +157,8 @@ special_overflow (void)
{
mpfr_t x, y;
- mpfr_set_emin (-125);
- mpfr_set_emax (128);
+ set_emin (-125);
+ set_emax (128);
mpfr_init2 (x, 24);
mpfr_init2 (y, 48);
mpfr_set_str_binary (x, "0.101100100000000000110100E0");
@@ -172,8 +172,8 @@ special_overflow (void)
}
mpfr_clear (y);
mpfr_clear (x);
- mpfr_set_emin (MPFR_EMIN_MIN);
- mpfr_set_emax (MPFR_EMAX_MAX);
+ set_emin (MPFR_EMIN_MIN);
+ set_emax (MPFR_EMAX_MAX);
}
int
diff --git a/tests/tatan.c b/tests/tatan.c
index f0f146ad7..53f528929 100644
--- a/tests/tatan.c
+++ b/tests/tatan.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_atan.
-Copyright 2001, 2002, 2003, 2004 Free Software Foundation.
+Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation.
Written by Paul Zimmermann, INRIA Lorraine.
This file is part of the MPFR Library.
@@ -29,7 +29,7 @@ static void
special (void)
{
mpfr_t x, y, z;
- mp_rnd_t r;
+ int r;
mpfr_init2 (x, 53);
mpfr_init2 (y, 53);
@@ -55,12 +55,13 @@ special (void)
for (r = 0; r < GMP_RND_MAX ; r++)
{
mpfr_set_inf (x, 1);
- mpfr_atan (y, x, r);
- mpfr_const_pi (x, r);
- mpfr_div_2exp (x, x, 1, r);
+ mpfr_atan (y, x, (mp_rnd_t) r);
+ mpfr_const_pi (x, (mp_rnd_t) r);
+ mpfr_div_2exp (x, x, 1, (mp_rnd_t) r);
if (mpfr_cmp (x, y))
{
- printf ("Error: mpfr_atan(+Inf), rnd=%s\n", mpfr_print_rnd_mode (r));
+ printf ("Error: mpfr_atan(+Inf), rnd=%s\n",
+ mpfr_print_rnd_mode ((mp_rnd_t) r));
exit (1);
}
}
@@ -69,13 +70,14 @@ special (void)
for (r = 0; r < GMP_RND_MAX ; r++)
{
mpfr_set_inf (x, -1);
- mpfr_atan (y, x, r);
- mpfr_const_pi (x, MPFR_INVERT_RND(r));
- mpfr_neg (x, x, r);
- mpfr_div_2exp (x, x, 1, r);
+ mpfr_atan (y, x, (mp_rnd_t) r);
+ mpfr_const_pi (x, MPFR_INVERT_RND((mp_rnd_t) r));
+ mpfr_neg (x, x, (mp_rnd_t) r);
+ mpfr_div_2exp (x, x, 1, (mp_rnd_t) r);
if (mpfr_cmp (x, y))
{
- printf ("Error: mpfr_atan(-Inf), rnd=%s\n", mpfr_print_rnd_mode (r));
+ printf ("Error: mpfr_atan(-Inf), rnd=%s\n",
+ mpfr_print_rnd_mode ((mp_rnd_t) r));
exit (1);
}
}
@@ -157,8 +159,8 @@ special_overflow (void)
{
mpfr_t x, y;
- mpfr_set_emin (-125);
- mpfr_set_emax (128);
+ set_emin (-125);
+ set_emax (128);
mpfr_init2 (x, 24);
mpfr_init2 (y, 48);
mpfr_set_str_binary (x, "0.101101010001001101111010E0");
@@ -172,8 +174,8 @@ special_overflow (void)
}
mpfr_clear (y);
mpfr_clear (x);
- mpfr_set_emin (MPFR_EMIN_MIN);
- mpfr_set_emax (MPFR_EMAX_MAX);
+ set_emin (MPFR_EMIN_MIN);
+ set_emax (MPFR_EMAX_MAX);
}
int
diff --git a/tests/tcan_round.c b/tests/tcan_round.c
index e0b1d0119..d2679b43e 100644
--- a/tests/tcan_round.c
+++ b/tests/tcan_round.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_can_round.
-Copyright 1999, 2001, 2002, 2003 Free Software Foundation, Inc.
+Copyright 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -62,10 +62,10 @@ main (void)
for (i = 30; i < 99; i++)
for (j = 30; j < 99; j++)
{
- mp_rnd_t r1, r2;
+ int r1, r2;
for (r1 = 0; r1 < GMP_RND_MAX ; r1++)
for (r2 = 0; r2 < GMP_RND_MAX ; r2++)
- mpfr_can_round (x, i, r1, r2, j); /* test for assertions */
+ mpfr_can_round (x, i, (mp_rnd_t) r1, (mp_rnd_t) r2, j); /* test for assertions */
}
mpfr_clear (x);
diff --git a/tests/tcbrt.c b/tests/tcbrt.c
index bac5b7418..ac64e01ba 100644
--- a/tests/tcbrt.c
+++ b/tests/tcbrt.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_cbrt.
-Copyright 2002, 2003, 2004 Free Software Foundation, Inc.
+Copyright 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -136,7 +136,7 @@ int
main (void)
{
mpfr_t x;
- mp_rnd_t r;
+ int r;
mp_prec_t p;
tests_start_mpfr ();
@@ -151,21 +151,21 @@ main (void)
for (r = 0; r < GMP_RND_MAX; r++)
{
mpfr_set_ui (x, 1, GMP_RNDN);
- mpfr_cbrt (x, x, r);
+ mpfr_cbrt (x, x, (mp_rnd_t) r);
if (mpfr_cmp_ui (x, 1))
{
printf ("Error in mpfr_cbrt for x=1, rnd=%s\ngot ",
- mpfr_print_rnd_mode (r));
+ mpfr_print_rnd_mode ((mp_rnd_t) r));
mpfr_out_str (stdout, 2, 0, x, GMP_RNDN);
printf ("\n");
exit (1);
}
mpfr_set_si (x, -1, GMP_RNDN);
- mpfr_cbrt (x, x, r);
+ mpfr_cbrt (x, x, (mp_rnd_t) r);
if (mpfr_cmp_si (x, -1))
{
printf ("Error in mpfr_cbrt for x=-1, rnd=%s\ngot ",
- mpfr_print_rnd_mode (r));
+ mpfr_print_rnd_mode ((mp_rnd_t) r));
mpfr_out_str (stdout, 2, 0, x, GMP_RNDN);
printf ("\n");
exit (1);
@@ -183,7 +183,7 @@ main (void)
{
printf ("Error in mpfr_cbrt for "
"x = 27.0 * 2^(%d), rnd=%s\ngot ",
- 3*i, mpfr_print_rnd_mode (r));
+ 3*i, mpfr_print_rnd_mode ((mp_rnd_t) r));
mpfr_out_str (stdout, 2, 0, x, GMP_RNDN);
printf ("\ninstead of 3 * 2^(%d)\n", i);
exit (1);
diff --git a/tests/tcmp.c b/tests/tcmp.c
index f40e9dbe1..725eec599 100644
--- a/tests/tcmp.c
+++ b/tests/tcmp.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_cmp.
-Copyright 1999, 2001, 2002, 2003 Free Software Foundation, Inc.
+Copyright 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -76,23 +76,24 @@ main (void)
exit (1);
}
- mpfr_set_prec(xx, 53); mpfr_set_prec(yy, 200);
- mpfr_set_ui(xx, 1, 0);
- mpfr_set_ui(yy, 1, 0);
- if (mpfr_cmp(xx, yy) != 0)
+ mpfr_set_prec (xx, 53);
+ mpfr_set_prec (yy, 200);
+ mpfr_set_ui (xx, 1, (mp_rnd_t) 0);
+ mpfr_set_ui (yy, 1, (mp_rnd_t) 0);
+ if (mpfr_cmp (xx, yy) != 0)
{
printf ("Error in mpfr_cmp: 1.0 != 1.0\n");
exit (1);
}
- mpfr_set_prec(yy, 31);
- mpfr_set_str(xx, "1.0000000002", 10, 0);
- mpfr_set_ui(yy, 1, 0);
- if (!(mpfr_cmp(xx,yy)>0))
+ mpfr_set_prec (yy, 31);
+ mpfr_set_str (xx, "1.0000000002", 10, (mp_rnd_t) 0);
+ mpfr_set_ui (yy, 1, (mp_rnd_t) 0);
+ if (!(mpfr_cmp (xx,yy)>0))
{
printf ("Error in mpfr_cmp: not 1.0000000002 > 1.0\n");
exit (1);
}
- mpfr_set_prec(yy, 53);
+ mpfr_set_prec (yy, 53);
/* bug found by Gerardo Ballabio */
mpfr_set_ui(xx, 0, GMP_RNDN);
diff --git a/tests/tcmpabs.c b/tests/tcmpabs.c
index a0a9a9e9c..54869dfa0 100644
--- a/tests/tcmpabs.c
+++ b/tests/tcmpabs.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_cmpabs.
-Copyright 2004 Free Software Foundation, Inc.
+Copyright 2004, 2005 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -65,14 +65,14 @@ main (void)
mpfr_set_prec(xx, 53);
mpfr_set_prec(yy, 200);
- mpfr_set_ui(xx, 1, 0);
- mpfr_set_ui(yy, 1, 0);
+ mpfr_set_ui (xx, 1, (mp_rnd_t) 0);
+ mpfr_set_ui (yy, 1, (mp_rnd_t) 0);
if (mpfr_cmpabs(xx, yy) != 0)
ERROR ("Error in mpfr_cmpabs: 1.0 != 1.0\n");
- mpfr_set_prec(yy, 31);
- mpfr_set_str(xx, "-1.0000000002", 10, 0);
- mpfr_set_ui(yy, 1, 0);
+ mpfr_set_prec (yy, 31);
+ mpfr_set_str (xx, "-1.0000000002", 10, (mp_rnd_t) 0);
+ mpfr_set_ui (yy, 1, (mp_rnd_t) 0);
if (!(mpfr_cmpabs(xx,yy)>0))
ERROR ("Error in mpfr_cmpabs: not 1.0000000002 > 1.0\n");
mpfr_set_prec(yy, 53);
diff --git a/tests/tconst_euler.c b/tests/tconst_euler.c
index c8354792b..d72786817 100644
--- a/tests/tconst_euler.c
+++ b/tests/tconst_euler.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_const_euler.
-Copyright 2001, 2004 Free Software Foundation.
+Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation.
This file is part of the MPFR Library.
@@ -29,7 +29,7 @@ main (int argc, char *argv[])
{
mpfr_t gamma, y, z, t;
unsigned int err, prec, yprec, p0 = 2, p1 = 200;
- mp_rnd_t rnd;
+ int rnd;
tests_start_mpfr ();
@@ -68,16 +68,16 @@ main (int argc, char *argv[])
for (rnd = 0; rnd < GMP_RND_MAX; rnd++)
{
mpfr_set_prec (y, yprec);
- mpfr_const_euler (y, rnd);
+ mpfr_const_euler (y, (mp_rnd_t) rnd);
err = (rnd == GMP_RNDN) ? yprec + 1 : yprec;
- if (mpfr_can_round (y, err, rnd, rnd, prec))
+ if (mpfr_can_round (y, err, (mp_rnd_t) rnd, (mp_rnd_t) rnd, prec))
{
- mpfr_set (t, y, rnd);
- mpfr_const_euler (z, rnd);
+ mpfr_set (t, y, (mp_rnd_t) rnd);
+ mpfr_const_euler (z, (mp_rnd_t) rnd);
if (mpfr_cmp (t, z))
{
printf ("results differ for prec=%u rnd_mode=%s\n", prec,
- mpfr_print_rnd_mode (rnd));
+ mpfr_print_rnd_mode ((mp_rnd_t) rnd));
printf (" got ");
mpfr_out_str (stdout, 2, prec, z, GMP_RNDN);
puts ("");
diff --git a/tests/tconst_log2.c b/tests/tconst_log2.c
index 119f99a7a..722faa8d0 100644
--- a/tests/tconst_log2.c
+++ b/tests/tconst_log2.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_const_log2.
-Copyright 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+Copyright 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -43,7 +43,7 @@ check (mp_prec_t p0, mp_prec_t p1)
mpfr_set_prec (x, p0);
mpfr_set_prec (y, p0);
{
- rnd = RND_RAND ();
+ rnd = (mp_rnd_t) RND_RAND ();
mpfr_const_log2 (x, rnd);
mpfr_set (y, z, rnd);
if (mpfr_cmp (x, y) && mpfr_can_round (z, mpfr_get_prec(z), GMP_RNDN,
@@ -135,7 +135,7 @@ main (int argc, char *argv[])
tests_start_mpfr ();
p = (argc>1) ? atoi(argv[1]) : 53;
- rnd = (argc>2) ? atoi(argv[2]) : GMP_RNDZ;
+ rnd = (argc>2) ? (mp_rnd_t) atoi(argv[2]) : GMP_RNDZ;
mpfr_init (x);
diff --git a/tests/tconst_pi.c b/tests/tconst_pi.c
index 9fc388136..f4a92da05 100644
--- a/tests/tconst_pi.c
+++ b/tests/tconst_pi.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_const_pi.
-Copyright 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+Copyright 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -55,7 +55,7 @@ main (int argc, char *argv[])
{
mpfr_t x;
int p;
- unsigned char rnd;
+ mp_rnd_t rnd;
tests_start_mpfr ();
@@ -67,7 +67,7 @@ main (int argc, char *argv[])
p = a;
}
- rnd = (argc > 2) ? atoi(argv[2]) : GMP_RNDZ;
+ rnd = (argc > 2) ? (mp_rnd_t) atoi(argv[2]) : GMP_RNDZ;
mpfr_init2 (x, p);
mpfr_const_pi (x, rnd);
diff --git a/tests/tcos.c b/tests/tcos.c
index 5c02f6709..1500508ee 100644
--- a/tests/tcos.c
+++ b/tests/tcos.c
@@ -121,12 +121,12 @@ special_overflow (void)
mpfr_init2 (y, 73);
/* Check special case: An overflow in const_pi could occurs! */
- mpfr_set_emin (-125);
- mpfr_set_emax (128);
+ set_emin (-125);
+ set_emax (128);
mpfr_set_str_binary (x, "0.111101010110110011101101E6");
mpfr_cos (y, x, GMP_RNDZ);
- mpfr_set_emin (MPFR_EMIN_MIN);
- mpfr_set_emax (MPFR_EMAX_MAX);
+ set_emin (MPFR_EMIN_MIN);
+ set_emax (MPFR_EMAX_MAX);
mpfr_clear (x);
mpfr_clear (y);
diff --git a/tests/tcosh.c b/tests/tcosh.c
index d48a4ed68..74b138a7b 100644
--- a/tests/tcosh.c
+++ b/tests/tcosh.c
@@ -110,8 +110,8 @@ special_overflow (void)
3. cosh(x) exp overflow even with the largest range of exp */
mpfr_t x, y;
- mpfr_set_emin (-125);
- mpfr_set_emax (128);
+ set_emin (-125);
+ set_emax (128);
mpfr_init2 (x, 24);
mpfr_init2 (y, 24);
@@ -134,8 +134,8 @@ special_overflow (void)
exit (1);
}
- mpfr_set_emin (MPFR_EMIN_MIN);
- mpfr_set_emax (MPFR_EMAX_MAX);
+ set_emin (MPFR_EMIN_MIN);
+ set_emax (MPFR_EMAX_MAX);
mpfr_set_str_binary (x, "0.101100100000000000110100E1000000");
mpfr_cosh (y, x, GMP_RNDN);
diff --git a/tests/tdiv.c b/tests/tdiv.c
index 4e9457b56..717a47359 100644
--- a/tests/tdiv.c
+++ b/tests/tdiv.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_div.
-Copyright 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+Copyright 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -211,11 +211,11 @@ check_convergence (void)
for (j = 0;j < GMP_RND_MAX; j++)
{
mpfr_set_ui (y, 1, GMP_RNDN);
- mpfr_div (y, x, y, j);
+ mpfr_div (y, x, y, (mp_rnd_t) j);
if (mpfr_cmp_ui (y, 1))
{
printf ("mpfr_div failed for x=1.0, y=1.0, prec=%d rnd=%s\n",
- i, mpfr_print_rnd_mode(j));
+ i, mpfr_print_rnd_mode ((mp_rnd_t) j));
printf ("got "); mpfr_print_binary(y); puts ("");
exit (1);
}
@@ -428,7 +428,7 @@ check_inexact (void)
mpfr_set_prec (y, py);
mpfr_set_prec (z, py + pu);
{
- rnd = RND_RAND ();
+ rnd = (mp_rnd_t) RND_RAND ();
inexact = mpfr_div (y, x, u, rnd);
if (mpfr_mul (z, y, u, rnd))
{
@@ -544,17 +544,17 @@ check_nan (void)
/* check overflow */
emax = mpfr_get_emax ();
- mpfr_set_emax (1);
+ set_emax (1);
mpfr_set_ui (a, 1, GMP_RNDZ);
mpfr_set_ui (d, 1, GMP_RNDZ);
mpfr_div_2exp (d, d, 1, GMP_RNDZ);
mpfr_div (q, a, d, GMP_RNDU); /* 1 / 0.5 = 2 -> overflow */
MPFR_ASSERTN (mpfr_inf_p (q) && mpfr_sgn (q) > 0);
- mpfr_set_emax (emax);
+ set_emax (emax);
/* check underflow */
emin = mpfr_get_emin ();
- mpfr_set_emin (-1);
+ set_emin (-1);
mpfr_set_ui (a, 1, GMP_RNDZ);
mpfr_div_2exp (a, a, 2, GMP_RNDZ);
mpfr_set_ui (d, 2, GMP_RNDZ);
@@ -562,7 +562,7 @@ check_nan (void)
MPFR_ASSERTN (mpfr_cmp_ui (q, 0) == 0 && MPFR_IS_POS (q));
mpfr_div (q, a, d, GMP_RNDN); /* 0.5*2^(-2) -> underflow */
MPFR_ASSERTN (mpfr_cmp_ui (q, 0) == 0 && MPFR_IS_POS (q));
- mpfr_set_emin (emin);
+ set_emin (emin);
mpfr_clear (a);
mpfr_clear (d);
diff --git a/tests/tdiv_ui.c b/tests/tdiv_ui.c
index 6acd3e1db..68a3ae916 100644
--- a/tests/tdiv_ui.c
+++ b/tests/tdiv_ui.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_div_ui.
-Copyright 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation.
+Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation.
This file is part of the MPFR Library.
@@ -140,7 +140,7 @@ check_inexact (void)
mp_prec_t px, py;
int inexact, cmp;
unsigned long int u;
- mp_rnd_t rnd;
+ int rnd;
mpfr_init (x);
mpfr_init (y);
@@ -161,8 +161,8 @@ check_inexact (void)
mpfr_set_prec (z, py + mp_bits_per_limb);
for (rnd = 0; rnd < GMP_RND_MAX; rnd++)
{
- inexact = mpfr_div_ui (y, x, u, rnd);
- if (mpfr_mul_ui (z, y, u, rnd))
+ inexact = mpfr_div_ui (y, x, u, (mp_rnd_t) rnd);
+ if (mpfr_mul_ui (z, y, u, (mp_rnd_t) rnd))
{
printf ("z <- y * u should be exact for u=%lu\n", u);
printf ("y="); mpfr_print_binary (y); puts ("");
@@ -175,7 +175,7 @@ check_inexact (void)
((inexact < 0) && (cmp >= 0)))
{
printf ("Wrong inexact flag for u=%lu, rnd=%s\n", u,
- mpfr_print_rnd_mode(rnd));
+ mpfr_print_rnd_mode ((mp_rnd_t) rnd));
printf ("x="); mpfr_print_binary (x); puts ("");
printf ("y="); mpfr_print_binary (y); puts ("");
exit (1);
diff --git a/tests/teq.c b/tests/teq.c
index f0b7afb62..42c5e6b8f 100644
--- a/tests/teq.c
+++ b/tests/teq.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_eq.
-Copyright 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -75,8 +75,8 @@ special (void)
mpfr_init2 (y, 53);
mpfr_init2 (z, 53);
- mpfr_set_str (x, "1", 10, 0);
- mpfr_set_str (y, "1e-10000", 10, 0);
+ mpfr_set_str (x, "1", 10, (mp_rnd_t) 0);
+ mpfr_set_str (y, "1e-10000", 10, (mp_rnd_t) 0);
mpfr_add (z, x, y, GMP_RNDU);
for (i = 1; i <= 52; i++)
diff --git a/tests/tests.c b/tests/tests.c
index 495410f18..ef5a5a1ae 100644
--- a/tests/tests.c
+++ b/tests/tests.c
@@ -1,6 +1,6 @@
/* Miscellaneous support for test programs.
-Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -27,6 +27,7 @@ MA 02111-1307, USA. */
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <float.h>
#if TIME_WITH_SYS_TIME
@@ -38,6 +39,10 @@ MA 02111-1307, USA. */
# include <time.h>
#endif
+#if HAVE_SYS_FPU_H
+# include <sys/fpu.h>
+#endif
+
#include "mpfr-test.h"
static void tests_rand_start (void);
@@ -61,7 +66,7 @@ tests_end_mpfr (void)
tests_memory_end ();
}
-void
+static void
tests_rand_start (void)
{
gmp_randstate_ptr rands;
@@ -105,7 +110,7 @@ tests_rand_start (void)
}
}
-void
+static void
tests_rand_end (void)
{
RANDS_CLEAR ();
@@ -116,7 +121,7 @@ void
mpfr_test_init ()
{
double c, d, eps;
-#ifdef __mips
+#if HAVE_FPC_CSR
/* to get denormalized numbers on IRIX64 */
union fpc_csr exp;
@@ -287,3 +292,42 @@ ld_trace (const char *name, long double ld)
}
printf ("] %.20Lg\n", ld);
}
+
+/* Open a file in the src directory - can't use fopen directly */
+FILE *src_fopen (const char *filename, const char *mode)
+{
+ const char *srcdir = getenv ("srcdir");
+ char *buffer;
+ FILE *f;
+
+ if (srcdir == NULL)
+ return fopen (filename, mode);
+ buffer = (char*) malloc (strlen (filename) + strlen (srcdir) + 1);
+ if (buffer == NULL)
+ {
+ printf ("src_fopen: failed to alloc memory)\n");
+ exit (1);
+ }
+ sprintf (buffer, "%s/%s", srcdir, filename);
+ f = fopen (buffer, mode);
+ free (buffer);
+ return f;
+}
+
+void set_emin (mp_exp_t exponent)
+{
+ if (mpfr_set_emin (exponent))
+ {
+ printf ("set_emin: setting emin to %ld failed\n", (long int) exponent);
+ exit (1);
+ }
+}
+
+void set_emax (mp_exp_t exponent)
+{
+ if (mpfr_set_emax (exponent))
+ {
+ printf ("set_emax: setting emax to %ld failed\n", (long int) exponent);
+ exit (1);
+ }
+}
diff --git a/tests/texceptions.c b/tests/texceptions.c
index 0d99daaec..282c13d37 100644
--- a/tests/texceptions.c
+++ b/tests/texceptions.c
@@ -1,6 +1,6 @@
/* Test file for exceptions.
-Copyright 2001, 2002, 2003, 2004 Free Software Foundation.
+Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation.
This file is part of the MPFR Library.
@@ -30,18 +30,19 @@ MA 02111-1307, USA. */
static void
check_default_rnd (void)
{
- mp_rnd_t r, t;
+ int r;
+ mp_rnd_t t;
for(r = 0 ; r < GMP_RND_MAX ; r++)
{
- mpfr_set_default_rounding_mode (r);
+ mpfr_set_default_rounding_mode ((mp_rnd_t) r);
t = mpfr_get_default_rounding_mode();
- if (r !=t)
+ if ((mp_rnd_t) r != t)
ERROR("ERROR in setting / getting default rounding mode (1)\n");
}
- mpfr_set_default_rounding_mode(4);
+ mpfr_set_default_rounding_mode ((mp_rnd_t) 4);
if (mpfr_get_default_rounding_mode() != GMP_RNDD)
ERROR("ERROR in setting / getting default rounding mode (2)\n");
- mpfr_set_default_rounding_mode(-1);
+ mpfr_set_default_rounding_mode ((mp_rnd_t) -1);
if (mpfr_get_default_rounding_mode() != GMP_RNDD)
ERROR("ERROR in setting / getting default rounding mode (3)\n");
}
@@ -82,8 +83,8 @@ mpfr_set_double_range (void)
(We have to add one for mpfr since mantissa are between 1/2 and 1.)
*/
- mpfr_set_emin (-1021);
- mpfr_set_emax (1024);
+ set_emin (-1021);
+ set_emax (1024);
}
static void
@@ -137,7 +138,7 @@ test_set_underflow (void)
mpfr_t x, zero, min;
mpfr_ptr r[4];
int t[4] = { 1, -1, 1, -1 };
- mp_rnd_t i;
+ int i;
int s;
mpfr_inits (x, zero, min, (mpfr_ptr) 0);
@@ -154,11 +155,11 @@ test_set_underflow (void)
int inex;
j = s < 0 && i > 1 ? 5 - i : i;
- inex = mpfr_set_underflow (x, i, s);
+ inex = mpfr_set_underflow (x, (mp_rnd_t) i, s);
if (mpfr_cmp (x, r[j]) || inex * t[j] <= 0)
{
printf ("Error in test_set_underflow, sign = %d,"
- " rnd_mode = %s\n", s, mpfr_print_rnd_mode (i));
+ " rnd_mode = %s\n", s, mpfr_print_rnd_mode ((mp_rnd_t) i));
printf ("Got\n");
mpfr_out_str (stdout, 2, 0, x, GMP_RNDN);
printf (", inex = %d\ninstead of\n", inex);
@@ -180,7 +181,7 @@ test_set_overflow (void)
mpfr_t x, inf, max;
mpfr_ptr r[4];
int t[4] = { 1, -1, 1, -1 };
- mp_rnd_t i;
+ int i;
int s;
mpfr_inits2 (32, x, inf, max, (mpfr_ptr) 0);
@@ -197,11 +198,11 @@ test_set_overflow (void)
int inex;
j = s < 0 && i > 1 ? 5 - i : i;
- inex = mpfr_set_overflow (x, i, s);
+ inex = mpfr_set_overflow (x, (mp_rnd_t) i, s);
if (mpfr_cmp (x, r[j]) || inex * t[j] <= 0)
{
printf ("Error in test_set_overflow, sign = %d,"
- " rnd_mode = %s\n", s, mpfr_print_rnd_mode (i));
+ " rnd_mode = %s\n", s, mpfr_print_rnd_mode ((mp_rnd_t) i));
printf ("Got\n");
mpfr_out_str (stdout, 2, 0, x, GMP_RNDN);
printf (", inex = %d\ninstead of\n", inex);
@@ -249,7 +250,7 @@ main (int argc, char *argv[])
exit (1);
}
- mpfr_set_emax (1025);
+ set_emax (1025);
mpfr_set_ui (x, 1, GMP_RNDN);
mpfr_mul_2exp (x, x, 1024, GMP_RNDN);
mpfr_set_double_range ();
@@ -293,7 +294,7 @@ main (int argc, char *argv[])
exit (1);
}
- mpfr_set_emin (-1026);
+ set_emin (-1026);
mpfr_set_ui (x, 1, GMP_RNDN);
mpfr_div_2exp (x, x, 1025, GMP_RNDN);
mpfr_set_double_range ();
diff --git a/tests/texp.c b/tests/texp.c
index d1bba9a51..3ff9acfae 100644
--- a/tests/texp.c
+++ b/tests/texp.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_exp.
-Copyright 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+Copyright 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -31,6 +31,8 @@ check3 (const char *op, mp_rnd_t rnd, const char *res)
mpfr_t x, y;
mpfr_inits2 (53, x, y, NULL);
+ /* y negative. If we forget to set the sign in mpfr_exp, we'll see it. */
+ mpfr_set_si (y, -1, GMP_RNDN);
mpfr_set_str1 (x, op);
mpfr_exp (y, x, rnd);
if (mpfr_cmp_str1 (y, res) )
@@ -142,7 +144,7 @@ compare_exp2_exp3 (int n)
mpfr_set_prec (y, prec);
mpfr_set_prec (z, prec);
mpfr_random (x);
- rnd = RND_RAND() ;
+ rnd = (mp_rnd_t) RND_RAND();
mpfr_exp_2 (y, x, rnd);
mpfr_exp_3 (z, x, rnd);
if (mpfr_cmp (y,z))
@@ -217,7 +219,7 @@ check_special ()
/* check overflow */
emax = mpfr_get_emax ();
- mpfr_set_emax (10);
+ set_emax (10);
mpfr_set_ui (x, 7, GMP_RNDN);
mpfr_exp (y, x, GMP_RNDN);
if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0)
@@ -225,11 +227,11 @@ check_special ()
printf ("Error for exp(7) for emax=10\n");
exit (1);
}
- mpfr_set_emax (emax);
+ set_emax (emax);
/* check underflow */
emin = mpfr_get_emin ();
- mpfr_set_emin (-10);
+ set_emin (-10);
mpfr_set_si (x, -9, GMP_RNDN);
mpfr_exp (y, x, GMP_RNDN);
if (mpfr_cmp_ui (y, 0) || mpfr_sgn (y) < 0)
@@ -239,7 +241,7 @@ check_special ()
printf ("Got "); mpfr_print_binary (y); puts ("");
exit (1);
}
- mpfr_set_emin (emin);
+ set_emin (emin);
/* check case EXP(x) < -precy */
mpfr_set_prec (y, 2);
@@ -295,8 +297,8 @@ check_special ()
mpfr_exp_3 (y, x, GMP_RNDN);
/* Check some little things about overflow detection */
- mpfr_set_emin (-125);
- mpfr_set_emax (128);
+ set_emin (-125);
+ set_emax (128);
mpfr_set_prec (x, 107);
mpfr_set_prec (y, 107);
mpfr_set_str_binary (x, "0.11110000000000000000000000000000000000000000000"
@@ -312,8 +314,8 @@ check_special ()
exit (1);
}
- mpfr_set_emin (MPFR_EMIN_MIN);
- mpfr_set_emax (MPFR_EMAX_MAX);
+ set_emin (MPFR_EMIN_MIN);
+ set_emax (MPFR_EMAX_MAX);
/* Check for overflow producing a segfault with HUGE exponent */
mpfr_set_ui (x, 3, GMP_RNDN);
@@ -385,6 +387,8 @@ main (int argc, char *argv[])
compare_exp2_exp3(500);
check_worst_cases();
check3("0.0", GMP_RNDU, "1.0");
+ check3("-1e-170", GMP_RNDU, "1.0");
+ check3("-1e-170", GMP_RNDN, "1.0");
check3("-8.88024741073346941839e-17", GMP_RNDU, "1.0");
check3("8.70772839244701057915e-01", GMP_RNDN, "2.38875626491680437269");
check3("1.0", GMP_RNDN, "2.71828182845904509080");
diff --git a/tests/texp2.c b/tests/texp2.c
index e304f85d6..771346efe 100644
--- a/tests/texp2.c
+++ b/tests/texp2.c
@@ -33,8 +33,8 @@ special_overflow (void)
{
mpfr_t x, y;
- mpfr_set_emin (-125);
- mpfr_set_emax (128);
+ set_emin (-125);
+ set_emax (128);
mpfr_init2 (x, 24);
mpfr_init2 (y, 24);
@@ -50,8 +50,8 @@ special_overflow (void)
mpfr_clear (y);
mpfr_clear (x);
- mpfr_set_emin (MPFR_EMIN_MIN);
- mpfr_set_emax (MPFR_EMAX_MAX);
+ set_emin (MPFR_EMIN_MIN);
+ set_emax (MPFR_EMAX_MAX);
}
int
@@ -102,7 +102,7 @@ main (int argc, char *argv[])
mpfr_set_prec (y, 10);
/* save emin */
emin = mpfr_get_emin ();
- mpfr_set_emin (-10);
+ set_emin (-10);
mpfr_set_si (x, -12, GMP_RNDN);
mpfr_exp2 (y, x, GMP_RNDN);
if (mpfr_cmp_ui (y, 0) || mpfr_sgn (y) < 0)
@@ -113,11 +113,11 @@ main (int argc, char *argv[])
exit (1);
}
/* restore emin */
- mpfr_set_emin (emin);
+ set_emin (emin);
/* save emax */
emax = mpfr_get_emax ();
- mpfr_set_emax (10);
+ set_emax (10);
mpfr_set_ui (x, 11, GMP_RNDN);
mpfr_exp2 (y, x, GMP_RNDN);
if (!mpfr_inf_p (y) || mpfr_sgn (y) < 0)
@@ -126,7 +126,7 @@ main (int argc, char *argv[])
exit (1);
}
/* restore emax */
- mpfr_set_emax (emax);
+ set_emax (emax);
MPFR_SET_INF(x);
diff --git a/tests/tfactorial.c b/tests/tfactorial.c
index ce28a3de3..8a2834fd1 100644
--- a/tests/tfactorial.c
+++ b/tests/tfactorial.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_factorial.
-Copyright 2001, 2002, 2003, 2004 Free Software Foundation.
+Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation.
This file is part of the MPFR Library.
@@ -74,7 +74,7 @@ test_int (void)
mpz_t f;
mpfr_t x, y;
mp_prec_t prec_f, p;
- mp_rnd_t r;
+ int r;
int inex1, inex2;
mpz_init (f);
@@ -92,19 +92,19 @@ test_int (void)
mpfr_set_prec (y, p);
for (r = 0; r < GMP_RND_MAX; r++)
{
- inex1 = mpfr_fac_ui (x, n, r);
- inex2 = mpfr_set_z (y, f, r);
+ inex1 = mpfr_fac_ui (x, n, (mp_rnd_t) r);
+ inex2 = mpfr_set_z (y, f, (mp_rnd_t) r);
if (mpfr_cmp (x, y))
{
printf ("Error for n=%lu prec=%lu rnd=%s\n",
- n, (unsigned long) p, mpfr_print_rnd_mode (r));
+ n, (unsigned long) p, mpfr_print_rnd_mode ((mp_rnd_t) r));
exit (1);
}
if ((inex1 < 0 && inex2 >= 0) || (inex1 == 0 && inex2 != 0)
|| (inex1 > 0 && inex2 <= 0))
{
printf ("Wrong inexact flag for n=%lu prec=%lu rnd=%s\n",
- n, (unsigned long) p, mpfr_print_rnd_mode (r));
+ n, (unsigned long) p, mpfr_print_rnd_mode ((mp_rnd_t) r));
exit (1);
}
}
@@ -120,7 +120,7 @@ int
main (int argc, char *argv[])
{
unsigned int prec, err, yprec, n, k, zeros;
- mp_rnd_t rnd;
+ int rnd;
mpfr_t x, y, z, t;
int inexact;
@@ -154,12 +154,12 @@ main (int argc, char *argv[])
for (n = 0; n < 50; n++)
for (rnd = 0; rnd < GMP_RND_MAX; rnd++)
{
- inexact = mpfr_fac_ui (y, n, rnd);
+ inexact = mpfr_fac_ui (y, n, (mp_rnd_t) rnd);
err = (rnd == GMP_RNDN) ? yprec + 1 : yprec;
- if (mpfr_can_round (y, err, rnd, rnd, prec))
+ if (mpfr_can_round (y, err, (mp_rnd_t) rnd, (mp_rnd_t) rnd, prec))
{
- mpfr_set (t, y, rnd);
- inexact = mpfr_fac_ui (z, n, rnd);
+ mpfr_set (t, y, (mp_rnd_t) rnd);
+ inexact = mpfr_fac_ui (z, n, (mp_rnd_t) rnd);
/* fact(n) ends with floor(n/2)+floor(n/4)+... zeros */
for (k=n/2, zeros=0; k; k >>= 1)
zeros += k;
@@ -187,7 +187,7 @@ main (int argc, char *argv[])
printf ("results differ for x=");
mpfr_out_str (stdout, 2, prec, x, GMP_RNDN);
printf (" prec=%u rnd_mode=%s\n", prec,
- mpfr_print_rnd_mode (rnd));
+ mpfr_print_rnd_mode ((mp_rnd_t) rnd));
printf (" got ");
mpfr_out_str (stdout, 2, prec, z, GMP_RNDN);
puts ("");
diff --git a/tests/tfma.c b/tests/tfma.c
index 8933476d2..8d5053224 100644
--- a/tests/tfma.c
+++ b/tests/tfma.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_fma.
-Copyright 2001, 2002, 2003, 2004 Free Software Foundation.
+Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation.
Adapted from tarctan.c.
This file is part of the MPFR Library.
@@ -260,7 +260,7 @@ main (int argc, char *argv[])
if (randlimb () % 2)
mpfr_neg (z, z, GMP_RNDN);
- rnd = RND_RAND ();
+ rnd = (mp_rnd_t) RND_RAND ();
mpfr_set_prec (slong, 2 * prec);
if (mpfr_mul (slong, x, y, rnd))
{
diff --git a/tests/tfrac.c b/tests/tfrac.c
index 478e194f1..e6b229a5d 100644
--- a/tests/tfrac.c
+++ b/tests/tfrac.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_frac.
-Copyright 2002, 2003, 2004 Free Software Foundation.
+Copyright 2002, 2003, 2004, 2005 Free Software Foundation.
This file is part of the MPFR Library.
@@ -113,16 +113,16 @@ check0 (mpfr_ptr ip, mpfr_ptr fp, mp_prec_t prec, mp_rnd_t rnd)
static void
check1 (mpfr_ptr ip, mpfr_ptr fp)
{
- mp_rnd_t rnd;
+ int rnd;
for (rnd = 0; rnd < GMP_RND_MAX ; rnd++)
{
- check0 (ip, fp, PMAX, rnd);
- check0 (ip, fp, 70, rnd);
+ check0 (ip, fp, PMAX, (mp_rnd_t) rnd);
+ check0 (ip, fp, 70, (mp_rnd_t) rnd);
mpfr_neg (fp, fp, GMP_RNDN);
mpfr_neg (ip, ip, GMP_RNDN);
- check0 (ip, fp, PMAX, rnd);
- check0 (ip, fp, 70, rnd);
+ check0 (ip, fp, PMAX, (mp_rnd_t) rnd);
+ check0 (ip, fp, 70, (mp_rnd_t) rnd);
mpfr_neg (fp, fp, GMP_RNDN);
mpfr_neg (ip, ip, GMP_RNDN);
}
diff --git a/tests/tgamma.c b/tests/tgamma.c
index 5894bfd06..1d0af89de 100644
--- a/tests/tgamma.c
+++ b/tests/tgamma.c
@@ -171,8 +171,8 @@ special_overflow (void)
{
mpfr_t x, y;
- mpfr_set_emin (-125);
- mpfr_set_emax (128);
+ set_emin (-125);
+ set_emax (128);
mpfr_init2 (x, 24);
mpfr_init2 (y, 24);
@@ -187,8 +187,8 @@ special_overflow (void)
mpfr_clear (y);
mpfr_clear (x);
- mpfr_set_emin (MPFR_EMIN_MIN);
- mpfr_set_emax (MPFR_EMAX_MAX);
+ set_emin (MPFR_EMIN_MIN);
+ set_emax (MPFR_EMAX_MAX);
}
int
diff --git a/tests/tgeneric.c b/tests/tgeneric.c
index b55cb8e1c..17cedd053 100644
--- a/tests/tgeneric.c
+++ b/tests/tgeneric.c
@@ -1,6 +1,6 @@
/* Generic test file for functions with one mpfr_t argument.
-Copyright 2001, 2002, 2003 Free Software Foundation.
+Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation.
This file is part of the MPFR Library.
@@ -48,7 +48,7 @@ test_generic (mp_prec_t p0, mp_prec_t p1, unsigned int N)
#else
mpfr_random (x);
#endif
- rnd = RND_RAND ();
+ rnd = (mp_rnd_t) RND_RAND ();
mpfr_set_prec (y, yprec);
compare = TEST_FUNCTION (y, x, rnd);
if (mpfr_can_round (y, yprec, rnd, rnd, prec))
diff --git a/tests/tget_d_2exp.c b/tests/tget_d_2exp.c
index bb47abee4..a009ca174 100644
--- a/tests/tget_d_2exp.c
+++ b/tests/tget_d_2exp.c
@@ -1,6 +1,6 @@
/* Test mpfr_get_d_2exp.
-Copyright 1999, 2000, 2001, 2002, 2003 Free Software Foundation.
+Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation.
This file is part of the MPFR Library.
@@ -49,7 +49,7 @@ check_round (void)
for (neg = 0; neg <= 1; neg++)
{
- got = mpfr_get_d_2exp (&got_exp, f, rnd_mode);
+ got = mpfr_get_d_2exp (&got_exp, f, (mp_rnd_t) rnd_mode);
if (neg == 0
? (got < 0.5 || got >= 1.0)
diff --git a/tests/tget_sj.c b/tests/tget_sj.c
index 77f3dde5c..a5591818b 100644
--- a/tests/tget_sj.c
+++ b/tests/tget_sj.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_get_sj and mpfr_get_uj.
-Copyright 2004 Free Software Foundation, Inc.
+Copyright 2004, 2005 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -62,7 +62,7 @@ check_sj (intmax_t s, mpfr_ptr x)
for (i = -1; i <= 1; i++)
{
- mpfr_rnd_t rnd;
+ int rnd;
mpfr_set_si_2exp (y, i, -2, GMP_RNDN);
mpfr_add (y, y, x, GMP_RNDN);
@@ -79,12 +79,12 @@ check_sj (intmax_t s, mpfr_ptr x)
if (rnd == GMP_RNDU && i > 0)
continue;
/* rint (y) == x == s */
- r = mpfr_get_sj (y, rnd);
+ r = mpfr_get_sj (y, (mp_rnd_t) rnd);
if (r != s)
{
printf ("Error in check_sj for y = ");
mpfr_out_str (stdout, 2, 0, y, GMP_RNDN);
- printf (" in %s\n", mpfr_print_rnd_mode (rnd));
+ printf (" in %s\n", mpfr_print_rnd_mode ((mp_rnd_t) rnd));
printf ("Got %jd instead of %jd.\n", r, s);
exit (1);
}
@@ -104,7 +104,7 @@ check_uj (uintmax_t u, mpfr_ptr x)
for (i = -1; i <= 1; i++)
{
- mpfr_rnd_t rnd;
+ int rnd;
mpfr_set_si_2exp (y, i, -2, GMP_RNDN);
mpfr_add (y, y, x, GMP_RNDN);
@@ -119,12 +119,12 @@ check_uj (uintmax_t u, mpfr_ptr x)
if (rnd == GMP_RNDU && i > 0)
continue;
/* rint (y) == x == u */
- r = mpfr_get_uj (y, rnd);
+ r = mpfr_get_uj (y, (mp_rnd_t) rnd);
if (r != u)
{
printf ("Error in check_uj for y = ");
mpfr_out_str (stdout, 2, 0, y, GMP_RNDN);
- printf (" in %s\n", mpfr_print_rnd_mode (rnd));
+ printf (" in %s\n", mpfr_print_rnd_mode ((mp_rnd_t) rnd));
printf ("Got %ju instead of %ju.\n", r, u);
exit (1);
}
diff --git a/tests/tget_str.c b/tests/tget_str.c
index e644bc4ea..a2d8d7de9 100644
--- a/tests/tget_str.c
+++ b/tests/tget_str.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_get_str.
-Copyright 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+Copyright 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -287,6 +287,7 @@ check_small (void)
exit (1);
}
mpfr_free_str (s);
+
mpfr_set_str_binary (x, "10100100001011001000011001101101000110100110000010111E89");
s = mpfr_get_str (NULL, &e, 10, 7, x, GMP_RNDN);
if (strcmp (s, "3575392") || e != 43)
@@ -295,6 +296,7 @@ check_small (void)
exit (1);
}
mpfr_free_str (s);
+
mpfr_set_str_binary (x, "11000011011110110010100110001010000001010011001011001E-73");
s = mpfr_get_str (NULL, &e, 10, 8, x, GMP_RNDN);
if (strcmp (s, "72822386") || e != -6)
@@ -303,6 +305,7 @@ check_small (void)
exit (1);
}
mpfr_free_str (s);
+
mpfr_set_str_binary (x, "10101010001101000111001100001000100011100010010001010E78");
s = mpfr_get_str (NULL, &e, 10, 9, x, GMP_RNDN);
if (strcmp (s, "180992873") || e != 40)
@@ -311,6 +314,7 @@ check_small (void)
exit (1);
}
mpfr_free_str (s);
+
mpfr_set_str_binary (x, "10110111001000100000001101111001100101101110011011101E91");
s = mpfr_get_str (NULL, &e, 10, 10, x, GMP_RNDN);
if (strcmp (s, "1595312255") || e != 44)
@@ -343,6 +347,7 @@ check_small (void)
exit (1);
}
mpfr_free_str (s);
+
mpfr_set_str_binary (x, "10010011010110011100010010100101100011101000011111111E92");
s = mpfr_get_str (NULL, &e, 10, 14, x, GMP_RNDN);
if (strcmp (s, "25672105101864") || e != 44)
@@ -351,6 +356,7 @@ check_small (void)
exit (1);
}
mpfr_free_str (s);
+
mpfr_set_str_binary (x, "100110111110110001000101110100100101101000011111001E87");
s = mpfr_get_str (NULL, &e, 10, 15, x, GMP_RNDN);
if (strcmp (s, "212231308858721") || e != 42)
@@ -359,6 +365,15 @@ check_small (void)
exit (1);
}
mpfr_free_str (s);
+ mpfr_set_str_binary (x, "10111010110000111000101100101111001011011100101001111E-128");
+ s = mpfr_get_str (NULL, &e, 10, 15, x, GMP_RNDN);
+ if (strcmp (s, "193109287087290") || e != -22)
+ {
+ printf ("Error in mpfr_get_str (22b): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+
mpfr_set_str_binary (x, "10001101101011010001111110000111010111010000110101010E80");
s = mpfr_get_str (NULL, &e, 10, 16, x, GMP_RNDN);
if (strcmp (s, "6026241735727920") || e != 40)
@@ -367,6 +382,7 @@ check_small (void)
exit (1);
}
mpfr_free_str (s);
+
mpfr_set_str_binary (x, "100010001011101001110101000110011001001000110001001E-81");
s = mpfr_get_str (NULL, &e, 10, 17, x, GMP_RNDN);
if (strcmp (s, "49741483709103481") || e != -9)
@@ -391,6 +407,7 @@ check_small (void)
exit (1);
}
mpfr_free_str (s);
+
mpfr_set_str_binary (x, "11111001010011100101000001111111110001001001110110001E-136");
s = mpfr_get_str (NULL, &e, 10, 9, x, GMP_RNDN);
if (strcmp (s, "100693858") || e != -24)
@@ -424,6 +441,324 @@ check_small (void)
}
mpfr_free_str (s);
+ /* 8116315218207718*2^(-293) ~ 0.5100000000000000000015*10^(-72) */
+ mpfr_set_str_binary (x, "11100110101011011111011100101011101110110001111100110E-293");
+ s = mpfr_get_str (NULL, &e, 10, 2, x, GMP_RNDU);
+ if (strcmp (s, "52") || e != -72)
+ {
+ printf ("Error in mpfr_get_str (31u): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+ s = mpfr_get_str (NULL, &e, 10, 2, x, GMP_RNDD);
+ if (strcmp (s, "51") || e != -72)
+ {
+ printf ("Error in mpfr_get_str (31d): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+
+ /* 6712731423444934*2^536 ~ .151000000000000000000067*10^178 */
+ mpfr_set_str_binary (x, "10111110110010011000110010011111101111000111111000110E536");
+ s = mpfr_get_str (NULL, &e, 10, 3, x, GMP_RNDU);
+ if (strcmp (s, "152") || e != 178)
+ {
+ printf ("Error in mpfr_get_str (32u): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+ s = mpfr_get_str (NULL, &e, 10, 3, x, GMP_RNDD);
+ if (strcmp (s, "151") || e != 178)
+ {
+ printf ("Error in mpfr_get_str (32d): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+
+ /* 3356365711722467*2^540 ~ .120800000000000000000054*10^179 */
+ mpfr_set_str_binary (x, "1011111011001001100011001001111110111100011111100011E540");
+ s = mpfr_get_str (NULL, &e, 10, 4, x, GMP_RNDU);
+ if (strcmp (s, "1209") || e != 179)
+ {
+ printf ("Error in mpfr_get_str (33u): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+ s = mpfr_get_str (NULL, &e, 10, 4, x, GMP_RNDD);
+ if (strcmp (s, "1208") || e != 179)
+ {
+ printf ("Error in mpfr_get_str (33d): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+
+ /* 6475049196144587*2^100 ~ .8208099999999999999999988*10^46 */
+ mpfr_set_str_binary (x, "10111000000010000010111011111001111010100011111001011E100");
+ s = mpfr_get_str (NULL, &e, 10, 5, x, GMP_RNDU);
+ if (strcmp (s, "82081") || e != 46)
+ {
+ printf ("Error in mpfr_get_str (34u): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+ s = mpfr_get_str (NULL, &e, 10, 5, x, GMP_RNDD);
+ if (strcmp (s, "82080") || e != 46)
+ {
+ printf ("Error in mpfr_get_str (34d): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+
+ /* 6722280709661868*2^364 ~ .25260100000000000000000012*10^126 */
+ mpfr_set_str_binary (x, "10111111000011110000011110001110001111010010010101100E364");
+ s = mpfr_get_str (NULL, &e, 10, 6, x, GMP_RNDU);
+ if (strcmp (s, "252602") || e != 126)
+ {
+ printf ("Error in mpfr_get_str (35u): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+ s = mpfr_get_str (NULL, &e, 10, 6, x, GMP_RNDD);
+ if (strcmp (s, "252601") || e != 126)
+ {
+ printf ("Error in mpfr_get_str (35d): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+
+ /* 5381065484265332*2^(-455) ~ .578389299999999999999999982*10^(-121) */
+ mpfr_set_str_binary (x, "10011000111100000110011110000101100111110011101110100E-455");
+ s = mpfr_get_str (NULL, &e, 10, 7, x, GMP_RNDU);
+ if (strcmp (s, "5783893") || e != -121)
+ {
+ printf ("Error in mpfr_get_str (36u): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+ s = mpfr_get_str (NULL, &e, 10, 7, x, GMP_RNDD);
+ if (strcmp (s, "5783892") || e != -121)
+ {
+ printf ("Error in mpfr_get_str (36d): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+
+ /* 8369123604277281*2^(-852) ~ .27869147000000000000000000056*10^(-240) */
+ mpfr_set_str_binary (x, "11101101110111010110001101111100000111010100000100001E-852");
+ s = mpfr_get_str (NULL, &e, 10, 8, x, GMP_RNDU);
+ if (strcmp (s, "27869148") || e != -240)
+ {
+ printf ("Error in mpfr_get_str (37u): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+ s = mpfr_get_str (NULL, &e, 10, 8, x, GMP_RNDD);
+ if (strcmp (s, "27869147") || e != -240)
+ {
+ printf ("Error in mpfr_get_str (37d): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+
+ /* 7976538478610756*2^377 ~ .245540326999999999999999999982*10^130 */
+ mpfr_set_str_binary (x, "11100010101101001111010010110100011100000100101000100E377");
+ s = mpfr_get_str (NULL, &e, 10, 9, x, GMP_RNDU);
+ if (strcmp (s, "245540327") || e != 130)
+ {
+ printf ("Error in mpfr_get_str (38u): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+ s = mpfr_get_str (NULL, &e, 10, 9, x, GMP_RNDD);
+ if (strcmp (s, "245540326") || e != 130)
+ {
+ printf ("Error in mpfr_get_str (38d): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+
+ /* 8942832835564782*2^(-382) ~ .9078555839000000000000000000038*10^(-99) */
+ mpfr_set_str_binary (x, "11111110001010111010110000110011100110001010011101110E-382");
+ s = mpfr_get_str (NULL, &e, 10, 10, x, GMP_RNDU);
+ if (strcmp (s, "9078555840") || e != -99)
+ {
+ printf ("Error in mpfr_get_str (39u): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+ s = mpfr_get_str (NULL, &e, 10, 10, x, GMP_RNDD);
+ if (strcmp (s, "9078555839") || e != -99)
+ {
+ printf ("Error in mpfr_get_str (39d): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+
+ /* 4471416417782391*2^(-380) ~ .18157111678000000000000000000077*10^(-98) */
+ mpfr_set_str_binary (x, "1111111000101011101011000011001110011000101001110111E-380");
+ s = mpfr_get_str (NULL, &e, 10, 11, x, GMP_RNDU);
+ if (strcmp (s, "18157111679") || e != -98)
+ {
+ printf ("Error in mpfr_get_str (40u): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+ s = mpfr_get_str (NULL, &e, 10, 11, x, GMP_RNDD);
+ if (strcmp (s, "18157111678") || e != -98)
+ {
+ printf ("Error in mpfr_get_str (40d): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+
+ /* 7225450889282194*2^711 ~ .778380362292999999999999999999971*10^230 */
+ mpfr_set_str_binary (x, "11001101010111000001001100001100110010000001010010010E711");
+ s = mpfr_get_str (NULL, &e, 10, 12, x, GMP_RNDU);
+ if (strcmp (s, "778380362293") || e != 230)
+ {
+ printf ("Error in mpfr_get_str (41u): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+ s = mpfr_get_str (NULL, &e, 10, 12, x, GMP_RNDD);
+ if (strcmp (s, "778380362292") || e != 230)
+ {
+ printf ("Error in mpfr_get_str (41d): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+
+ /* 3612725444641097*2^713 ~ .1556760724585999999999999999999942*10^231 */
+ mpfr_set_str_binary (x, "1100110101011100000100110000110011001000000101001001E713");
+ s = mpfr_get_str (NULL, &e, 10, 13, x, GMP_RNDU);
+ if (strcmp (s, "1556760724586") || e != 231)
+ {
+ printf ("Error in mpfr_get_str (42u): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+ s = mpfr_get_str (NULL, &e, 10, 13, x, GMP_RNDD);
+ if (strcmp (s, "1556760724585") || e != 231)
+ {
+ printf ("Error in mpfr_get_str (42d): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+
+ /* 6965949469487146*2^(-248) ~ .15400733123779000000000000000000016*10^(-58) */
+ mpfr_set_str_binary (x, "11000101111110111111001111111101001101111000000101010E-248");
+ s = mpfr_get_str (NULL, &e, 10, 14, x, GMP_RNDU);
+ if (strcmp (s, "15400733123780") || e != -58)
+ {
+ printf ("Error in mpfr_get_str (43u): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+ s = mpfr_get_str (NULL, &e, 10, 14, x, GMP_RNDD);
+ if (strcmp (s, "15400733123779") || e != -58)
+ {
+ printf ("Error in mpfr_get_str (43d): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+
+ /* 3482974734743573*2^(-244) ~ .12320586499023200000000000000000013*10^(-57) */
+ mpfr_set_str_binary (x, "1100010111111011111100111111110100110111100000010101E-244");
+ s = mpfr_get_str (NULL, &e, 10, 15, x, GMP_RNDU);
+ if (strcmp (s, "123205864990233") || e != -57)
+ {
+ printf ("Error in mpfr_get_str (44u): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+ s = mpfr_get_str (NULL, &e, 10, 15, x, GMP_RNDD);
+ if (strcmp (s, "123205864990232") || e != -57)
+ {
+ printf ("Error in mpfr_get_str (44d): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+
+ /* 7542952370752766*2^(-919) ~ .170206189963739699999999999999999974*10^(-260) */
+ mpfr_set_str_binary (x, "11010110011000100011001110100100111011100110011111110E-919");
+ s = mpfr_get_str (NULL, &e, 10, 16, x, GMP_RNDU);
+ if (strcmp (s, "1702061899637397") || e != -260)
+ {
+ printf ("Error in mpfr_get_str (45u): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+ s = mpfr_get_str (NULL, &e, 10, 16, x, GMP_RNDD);
+ if (strcmp (s, "1702061899637396") || e != -260)
+ {
+ printf ("Error in mpfr_get_str (45d): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+
+ /* 5592117679628511*2^165 ~ .26153245263757307000000000000000000074*10^66 */
+ mpfr_set_str_binary (x, "10011110111100000000001011011110101100010000011011111E165");
+ s = mpfr_get_str (NULL, &e, 10, 17, x, GMP_RNDU);
+ if (strcmp (s, "26153245263757308") || e != 66)
+ {
+ printf ("Error in mpfr_get_str (46u): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+ s = mpfr_get_str (NULL, &e, 10, 17, x, GMP_RNDD);
+ if (strcmp (s, "26153245263757307") || e != 66)
+ {
+ printf ("Error in mpfr_get_str (46d): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+
+ mpfr_set_str_binary (x, "11010010110111100001011010000110010000100001011011101E1223");
+ s = mpfr_get_str (NULL, &e, 10, 17, x, GMP_RNDN);
+ if (strcmp (s, "10716284017294180") || e != 385)
+ {
+ printf ("Error in mpfr_get_str (47n): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+ s = mpfr_get_str (NULL, &e, 10, 18, x, GMP_RNDU);
+ if (strcmp (s, "107162840172941805") || e != 385)
+ {
+ printf ("Error in mpfr_get_str (47u): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+ s = mpfr_get_str (NULL, &e, 10, 18, x, GMP_RNDD);
+ if (strcmp (s, "107162840172941804") || e != 385)
+ {
+ printf ("Error in mpfr_get_str (47d): s=%s e=%d\n", s, (int) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+
+ mpfr_set_str_binary (x, "11111101111011000001010100001101101000010010001111E122620");
+ s = mpfr_get_str (NULL, &e, 10, 17, x, GMP_RNDN);
+ if (strcmp (s, "22183435284042374") || e != 36928)
+ {
+ printf ("Error in mpfr_get_str (48n): s=%s e=%ld\n", s, (long) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+ s = mpfr_get_str (NULL, &e, 10, 18, x, GMP_RNDU);
+ if (strcmp (s, "221834352840423736") || e != 36928)
+ {
+ printf ("Error in mpfr_get_str (48u): s=%s e=%ld\n", s, (long) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+ s = mpfr_get_str (NULL, &e, 10, 18, x, GMP_RNDD);
+ if (strcmp (s, "221834352840423735") || e != 36928)
+ {
+ printf ("Error in mpfr_get_str (48d): s=%s e=%ld\n", s, (long) e);
+ exit (1);
+ }
+ mpfr_free_str (s);
+
mpfr_set_prec (x, 45);
mpfr_set_str_binary (x, "1E45");
s = mpfr_get_str (NULL, &e, 32, 9, x, GMP_RNDN);
@@ -628,7 +963,7 @@ check_special (int b, mp_prec_t p)
int i, j;
char s[MAX_DIGITS + 2], s2[MAX_DIGITS + 2], c;
mp_exp_t e;
- mp_rnd_t r;
+ int r;
size_t m;
/* check for invalid base */
@@ -647,7 +982,7 @@ check_special (int b, mp_prec_t p)
for (r = 0; r < GMP_RND_MAX; r++)
for (m= (i<3)? 2 : i-1 ; (int) m <= i+1 ; m++)
{
- mpfr_get_str (s, &e, b, m, x, r);
+ mpfr_get_str (s, &e, b, m, x, (mp_rnd_t) r);
/* s should be 1 followed by (m-1) zeros, and e should be i+1 */
if ((e != i+1) || strncmp (s, s2, m) != 0)
{
@@ -661,7 +996,7 @@ check_special (int b, mp_prec_t p)
for (r = 0; r < GMP_RND_MAX; r++)
if (i >= 2)
{
- mpfr_get_str (s, &e, b, i, x, r);
+ mpfr_get_str (s, &e, b, i, x, (mp_rnd_t) r);
/* should be i times (b-1) */
c = (b <= 10) ? '0' + b - 1 : 'a' + (b - 11);
for (j=0; (j < i) && (s[j] == c); j++);
@@ -752,7 +1087,7 @@ main (int argc, char *argv[])
mpfr_set_exp (x, (e == -10) ? mpfr_get_emin () :
((e == 10) ? mpfr_get_emax () : e));
b = 2 + (randlimb () % 35);
- r = RND_RAND();
+ r = (mp_rnd_t) RND_RAND();
mpfr_get_str (s, &f, b, m, x, r);
}
mpfr_clear (x);
diff --git a/tests/tgmpop.c b/tests/tgmpop.c
index 8f939f224..857ede7c7 100644
--- a/tests/tgmpop.c
+++ b/tests/tgmpop.c
@@ -1,7 +1,7 @@
/* Test file for mpfr_add_[q,z], mpfr_sub_[q,z], mpfr_div_[q,z], mpfr_mul_[q,z]
and mpfr_cmp_[q,z]
-Copyright 2004 Free Software Foundation.
+Copyright 2004, 2005 Free Software Foundation.
This file is part of the MPFR Library.
@@ -118,7 +118,7 @@ check_for_zero ()
mpq_t q;
mpz_t z;
mpfr_t x;
- mp_rnd_t r;
+ int r;
mpfr_sign_t i;
mpfr_init (x);
@@ -135,43 +135,43 @@ check_for_zero ()
i+=MPFR_SIGN_POS-MPFR_SIGN_NEG)
{
MPFR_SET_SIGN(x, i);
- mpfr_add_z (x, x, z, r);
+ mpfr_add_z (x, x, z, (mp_rnd_t) r);
if (!MPFR_IS_ZERO(x) || MPFR_SIGN(x)!=i)
{
printf("GMP Zero errors for add_z & rnd=%s & s=%d\n",
- mpfr_print_rnd_mode(r), i);
+ mpfr_print_rnd_mode ((mp_rnd_t) r), i);
mpfr_dump (x);
exit (1);
}
- mpfr_sub_z (x, x, z, r);
+ mpfr_sub_z (x, x, z, (mp_rnd_t) r);
if (!MPFR_IS_ZERO(x) || MPFR_SIGN(x)!=i)
{
printf("GMP Zero errors for sub_z & rnd=%s & s=%d\n",
- mpfr_print_rnd_mode(r), i);
+ mpfr_print_rnd_mode ((mp_rnd_t) r), i);
mpfr_dump (x);
exit (1);
}
- mpfr_mul_z (x, x, z, r);
+ mpfr_mul_z (x, x, z, (mp_rnd_t) r);
if (!MPFR_IS_ZERO(x) || MPFR_SIGN(x)!=i)
{
printf("GMP Zero errors for mul_z & rnd=%s & s=%d\n",
- mpfr_print_rnd_mode(r), i);
+ mpfr_print_rnd_mode ((mp_rnd_t) r), i);
mpfr_dump (x);
exit (1);
}
- mpfr_add_q (x, x, q, r);
+ mpfr_add_q (x, x, q, (mp_rnd_t) r);
if (!MPFR_IS_ZERO(x) || MPFR_SIGN(x)!=i)
{
printf("GMP Zero errors for add_q & rnd=%s & s=%d\n",
- mpfr_print_rnd_mode(r), i);
+ mpfr_print_rnd_mode ((mp_rnd_t) r), i);
mpfr_dump (x);
exit (1);
}
- mpfr_sub_q (x, x, q, r);
+ mpfr_sub_q (x, x, q, (mp_rnd_t) r);
if (!MPFR_IS_ZERO(x) || MPFR_SIGN(x)!=i)
{
printf("GMP Zero errors for sub_q & rnd=%s & s=%d\n",
- mpfr_print_rnd_mode(r), i);
+ mpfr_print_rnd_mode ((mp_rnd_t) r), i);
mpfr_dump (x);
exit (1);
}
@@ -389,7 +389,7 @@ test_genericz (mp_prec_t p0, mp_prec_t p1, unsigned int N,
{
mpfr_urandomb (arg1, RANDS);
mpz_urandomb (arg2, RANDS, 1024);
- rnd = RND_RAND ();
+ rnd = (mp_rnd_t) RND_RAND ();
mpfr_set_prec (dst_big, 2*prec);
compare = func(dst_big, arg1, arg2, rnd);
if (mpfr_can_round (dst_big, 2*prec, rnd, rnd, prec))
@@ -467,7 +467,7 @@ test_genericq (mp_prec_t p0, mp_prec_t p1, unsigned int N,
mpfr_urandomb (arg1, RANDS);
mpq_set_ui (arg2, randlimb (), randlimb() );
mpq_canonicalize (arg2);
- rnd = RND_RAND ();
+ rnd = (mp_rnd_t) RND_RAND ();
mpfr_set_prec (dst_big, prec+10);
compare = func(dst_big, arg1, arg2, rnd);
if (mpfr_can_round (dst_big, prec+10, rnd, rnd, prec))
diff --git a/tests/thypot.c b/tests/thypot.c
index fdb7eefab..0fa4982f1 100644
--- a/tests/thypot.c
+++ b/tests/thypot.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_hypot.
-Copyright 2001, 2002, 2003, 2004 Free Software Foundation.
+Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation.
Adapted from tarctan.c.
This file is part of the MPFR Library.
@@ -147,7 +147,7 @@ main (int argc, char *argv[])
mpfr_neg (x1, x1, GMP_RNDN);
if (randlimb () % 2)
mpfr_neg (x2, x2, GMP_RNDN);
- rnd = RND_RAND ();
+ rnd = (mp_rnd_t) RND_RAND ();
mpfr_set_prec (y, yprec);
compare =TEST_FUNCTION (y, x1,x2, rnd);
diff --git a/tests/tinp_str.c b/tests/tinp_str.c
index 534fd61da..4370be102 100644
--- a/tests/tinp_str.c
+++ b/tests/tinp_str.c
@@ -30,13 +30,12 @@ main (int argc, char *argv[])
mpfr_t x;
FILE *f;
int i;
-
tests_start_mpfr ();
mpfr_init (x);
mpfr_set_prec (x, 15);
- f = fopen ("inp_str.data", "r");
+ f = src_fopen ("inp_str.data", "r");
if (f == NULL)
{
printf ("Error, can't open inp_str.data\n");
diff --git a/tests/tlog.c b/tests/tlog.c
index 1ad90cf5f..d6c3efe49 100644
--- a/tests/tlog.c
+++ b/tests/tlog.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_log.
-Copyright 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+Copyright 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -159,14 +159,14 @@ special (void)
mpfr_init2 (y, 53);
/* Check special case: An overflow in const_pi could occurs! */
- mpfr_set_emin (-125);
- mpfr_set_emax (128);
+ set_emin (-125);
+ set_emax (128);
mpfr_set_prec (y, 24*2);
mpfr_set_prec (x, 24);
mpfr_set_str_binary (x, "0.111110101010101011110101E0");
mpfr_log (y, x, GMP_RNDN);
- mpfr_set_emin (MPFR_EMIN_MIN);
- mpfr_set_emax (MPFR_EMAX_MAX);
+ set_emin (MPFR_EMIN_MIN);
+ set_emax (MPFR_EMAX_MAX);
mpfr_set_prec (y, 53);
mpfr_set_prec (x, 53);
@@ -204,7 +204,7 @@ main (int argc, char *argv[])
if (argc==4)
{ /* tlog x prec rnd */
- check3 (atof(argv[1]), atoi(argv[2]), atoi(argv[3]));
+ check3 (atof(argv[1]), atoi(argv[2]), (mp_rnd_t) atoi(argv[3]));
goto done;
}
diff --git a/tests/tmul.c b/tests/tmul.c
index e825effda..55502c594 100644
--- a/tests/tmul.c
+++ b/tests/tmul.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_mul.
-Copyright 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+Copyright 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -217,7 +217,7 @@ check_exact (void)
{
mpfr_random (a);
mpfr_random (b);
- rnd = RND_RAND ();
+ rnd = (mp_rnd_t) RND_RAND ();
inexact = mpfr_mul (c, a, b, rnd);
if (mpfr_mul (d, a, b, rnd)) /* should be always exact */
{
@@ -300,17 +300,17 @@ check_max(void)
/* check underflow */
emin = mpfr_get_emin ();
- mpfr_set_emin (0);
+ set_emin (0);
mpfr_set_str_binary (xx, "0.1E0");
mpfr_set_str_binary (yy, "0.1E0");
mpfr_mul (zz, xx, yy, GMP_RNDN);
/* exact result is 0.1E-1, which should round to 0 */
MPFR_ASSERTN(mpfr_cmp_ui (zz, 0) == 0 && MPFR_IS_POS(zz));
- mpfr_set_emin (emin);
+ set_emin (emin);
/* coverage test for mpfr_powerof2_raw */
emin = mpfr_get_emin ();
- mpfr_set_emin (0);
+ set_emin (0);
mpfr_set_prec (xx, mp_bits_per_limb + 1);
mpfr_set_str_binary (xx, "0.1E0");
mpfr_nextabove (xx);
@@ -318,7 +318,7 @@ check_max(void)
mpfr_mul (zz, xx, yy, GMP_RNDN);
/* exact result is just above 0.1E-1, which should round to minfloat */
MPFR_ASSERTN(mpfr_cmp (zz, yy) == 0);
- mpfr_set_emin (emin);
+ set_emin (emin);
mpfr_clear(xx);
mpfr_clear(yy);
diff --git a/tests/tmul_ui.c b/tests/tmul_ui.c
index 09bfb3490..b0b040603 100644
--- a/tests/tmul_ui.c
+++ b/tests/tmul_ui.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_mul_ui.
-Copyright 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation.
+Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation.
This file is part of the MPFR Library.
@@ -31,7 +31,7 @@ check_inexact (mp_prec_t p)
unsigned long u;
mp_prec_t q;
int inexact, cmp;
- mp_rnd_t rnd;
+ int rnd;
mpfr_init2 (x, p);
mpfr_init (y);
@@ -48,7 +48,7 @@ check_inexact (mp_prec_t p)
for (rnd = 0; rnd < GMP_RND_MAX; rnd++)
{
mpfr_set_prec (y, q);
- inexact = mpfr_mul_ui (y, x, u, rnd);
+ inexact = mpfr_mul_ui (y, x, u, (mp_rnd_t) rnd);
cmp = mpfr_cmp (y, z);
if (((inexact == 0) && (cmp != 0)) ||
((inexact < 0) && (cmp >= 0)) ||
@@ -56,7 +56,7 @@ check_inexact (mp_prec_t p)
{
printf ("Wrong inexact flag for p=%u, q=%u, rnd=%s\n",
(unsigned int) p, (unsigned int) q,
- mpfr_print_rnd_mode (rnd));
+ mpfr_print_rnd_mode ((mp_rnd_t) rnd));
exit (1);
}
}
@@ -140,11 +140,11 @@ main (int argc, char *argv[])
MPFR_ASSERTN(mpfr_cmp_ui (x, 0) == 0 && MPFR_IS_POS(x));
emax = mpfr_get_emax ();
- mpfr_set_emax (0);
+ set_emax (0);
mpfr_set_str_binary (x, "0.1E0");
mpfr_mul_ui (x, x, 2, GMP_RNDN);
MPFR_ASSERTN(mpfr_inf_p (x) && MPFR_IS_POS(x));
- mpfr_set_emax (emax);
+ set_emax (emax);
mpfr_set_str (x, /*1.0/3.0*/
"0.333333333333333333333333333333333", 10, GMP_RNDZ);
diff --git a/tests/tout_str.c b/tests/tout_str.c
index c9997ce9b..4cdaf6642 100644
--- a/tests/tout_str.c
+++ b/tests/tout_str.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_out_str.
-Copyright 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+Copyright 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -135,7 +135,12 @@ main (int argc, char *argv[])
/* with no argument: prints to /dev/null,
tout_str N: prints N tests to stdout */
if (argc == 1)
- fout = fopen ("/dev/null", "w");
+ {
+ fout = fopen ("/dev/null", "w");
+ /* If we failed to open this device, try with a dummy file */
+ if (fout == NULL)
+ fout = fopen ("mpfrtest.txt", "w");
+ }
else
{
fout = stdout;
@@ -183,7 +188,7 @@ main (int argc, char *argv[])
#endif
r = RND_RAND ();
p = 2 + randlimb () % 35;
- check (d, r, p);
+ check (d, (mp_rnd_t) r, p);
}
fclose (fout);
diff --git a/tests/toutimpl.c b/tests/toutimpl.c
index 2fd4eacd6..c1e60382d 100644
--- a/tests/toutimpl.c
+++ b/tests/toutimpl.c
@@ -1,7 +1,7 @@
/* Test file for internal debugging-out functions:
mpfr_dump, mpfr_print_binary, mpfr_print_rnd_mode.
-Copyright 2004 Free Software Foundation, Inc.
+Copyright 2004, 2005 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -65,7 +65,7 @@ int main()
printf ("Error for printing GMP_RNDZ\n");
exit (1);
}
- if (mpfr_print_rnd_mode (-1) != NULL ||
+ if (mpfr_print_rnd_mode ((mp_rnd_t) -1) != NULL ||
mpfr_print_rnd_mode (GMP_RND_MAX) != NULL)
{
printf ("Error for illegal rounding mode values.\n");
diff --git a/tests/tpow.c b/tests/tpow.c
index c0017bf66..08d6f4b39 100644
--- a/tests/tpow.c
+++ b/tests/tpow.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_pow, mpfr_pow_ui and mpfr_pow_si.
-Copyright 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+Copyright 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -155,7 +155,7 @@ check_inexact (mp_prec_t p)
unsigned long u;
mp_prec_t q;
int inexact, cmp;
- mp_rnd_t rnd;
+ int rnd;
mpfr_init2 (x, p);
mpfr_init (y);
@@ -169,15 +169,15 @@ check_inexact (mp_prec_t p)
mpfr_set_prec (y, q);
mpfr_set_prec (z, q + 10);
mpfr_set_prec (t, q);
- inexact = mpfr_pow_ui (y, x, u, rnd);
- cmp = mpfr_pow_ui (z, x, u, rnd);
- if (mpfr_can_round (z, q + 10, rnd, rnd, q))
+ inexact = mpfr_pow_ui (y, x, u, (mp_rnd_t) rnd);
+ cmp = mpfr_pow_ui (z, x, u, (mp_rnd_t) rnd);
+ if (mpfr_can_round (z, q + 10, (mp_rnd_t) rnd, (mp_rnd_t) rnd, q))
{
- cmp = mpfr_set (t, z, rnd) || cmp;
+ cmp = mpfr_set (t, z, (mp_rnd_t) rnd) || cmp;
if (mpfr_cmp (y, t))
{
printf ("results differ for u=%lu rnd=%s\n",
- u, mpfr_print_rnd_mode(rnd));
+ u, mpfr_print_rnd_mode ((mp_rnd_t) rnd));
printf ("x="); mpfr_print_binary (x); puts ("");
printf ("y="); mpfr_print_binary (y); puts ("");
printf ("t="); mpfr_print_binary (t); puts ("");
@@ -189,7 +189,7 @@ check_inexact (mp_prec_t p)
{
printf ("Wrong inexact flag for p=%u, q=%u, rnd=%s\n",
(unsigned int) p, (unsigned int) q,
- mpfr_print_rnd_mode (rnd));
+ mpfr_print_rnd_mode ((mp_rnd_t) rnd));
printf ("expected %d, got %d\n", cmp, inexact);
printf ("u=%lu x=", u); mpfr_print_binary (x); puts ("");
printf ("y="); mpfr_print_binary (y); puts ("");
diff --git a/tests/tpow3.c b/tests/tpow3.c
index 0626d51dc..0e87a6138 100644
--- a/tests/tpow3.c
+++ b/tests/tpow3.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_pow.
-Copyright 2001, 2002, 2003 Free Software Foundation.
+Copyright 2001, 2002, 2003, 2005 Free Software Foundation.
Adapted from tarctan.c.
This file is part of the MPFR Library.
@@ -65,7 +65,7 @@ main (int argc, char *argv[])
mpfr_random (s);
if (randlimb () % 2)
mpfr_neg (s, s, GMP_RNDN);
- rnd = RND_RAND ();
+ rnd = (mp_rnd_t) RND_RAND ();
mpfr_set_prec (y, yprec);
compare = mpfr_pow (y, x, s, rnd);
err = (rnd == GMP_RNDN) ? yprec + 1 : yprec;
diff --git a/tests/trandom.c b/tests/trandom.c
index e5d1ff967..f59bbae4b 100644
--- a/tests/trandom.c
+++ b/tests/trandom.c
@@ -188,7 +188,7 @@ test_urandomb (long nbtests, mp_prec_t prec, int verbose)
/* coverage test */
emin = mpfr_get_emin ();
- mpfr_set_emin (1); /* the generated number in [0,1[ is not in the exponent
+ set_emin (1); /* the generated number in [0,1[ is not in the exponent
range, except if it is zero */
k = mpfr_urandomb (x, state);
if (MPFR_IS_ZERO(x) == 0 && (k == 0 || mpfr_nan_p (x) == 0))
@@ -197,7 +197,7 @@ test_urandomb (long nbtests, mp_prec_t prec, int verbose)
mpfr_dump (x);
exit (1);
}
- mpfr_set_emin (emin);
+ set_emin (emin);
mpfr_clear (x);
gmp_randclear (state);
diff --git a/tests/trint.c b/tests/trint.c
index e2b66939d..35f8e332d 100644
--- a/tests/trint.c
+++ b/tests/trint.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_rint, mpfr_trunc, mpfr_floor, mpfr_ceil, mpfr_round.
-Copyright 2002, 2003, 2004 Free Software Foundation.
+Copyright 2002, 2003, 2004, 2005 Free Software Foundation.
This file is part of the MPFR Library.
@@ -25,6 +25,10 @@ MA 02111-1307, USA. */
#include "mpfr-test.h"
+#if __MPFR_STDC (199901L)
+# include <math.h>
+#endif
+
static void
special (void)
{
@@ -64,13 +68,13 @@ special (void)
/* another coverage test */
emax = mpfr_get_emax ();
- mpfr_set_emax (1);
+ set_emax (1);
mpfr_set_prec (x, 3);
mpfr_set_str_binary (x, "1.11E0");
mpfr_set_prec (y, 2);
mpfr_rint (y, x, GMP_RNDU); /* x rounds to 1.0E1=0.1E2 which overflows */
MPFR_ASSERTN(mpfr_inf_p (y) && mpfr_sgn (y) > 0);
- mpfr_set_emax (emax);
+ set_emax (emax);
/* yet another */
mpfr_set_prec (x, 97);
@@ -130,6 +134,19 @@ special (void)
exit (1);
}
+ /* Bug found by Mark J Watkins */
+ mpfr_set_prec (x, 84);
+ mpfr_set_str_binary (x,
+ "0.110011010010001000000111101101001111111100101110010000000000000" \
+ "000000000000000000000E32");
+ mpfr_round (x, x);
+ if (mpfr_cmp_str (x, "0.1100110100100010000001111011010100000000000000" \
+ "00000000000000000000000000000000000000E32", 2, GMP_RNDN))
+ {
+ printf ("Rounding error when dest=src\n");
+ exit (1);
+ }
+
mpfr_clear (x);
mpfr_clear (y);
}
@@ -205,7 +222,7 @@ main (int argc, char *argv[])
mpz_t z;
mp_prec_t p;
mpfr_t x, y, t, u, v;
- mp_rnd_t r;
+ int r;
int inexact, sign_t;
tests_start_mpfr ();
@@ -246,7 +263,7 @@ main (int argc, char *argv[])
for (trint = 0; trint < 3; trint++)
{
if (trint == 2)
- inexact = mpfr_rint (y, x, r);
+ inexact = mpfr_rint (y, x, (mp_rnd_t) r);
else if (r == GMP_RNDN)
inexact = mpfr_round (y, x);
else if (r == GMP_RNDZ)
@@ -260,13 +277,14 @@ main (int argc, char *argv[])
mpfr_rint_floor (y, x, GMP_RNDD));
if (mpfr_sub (t, y, x, GMP_RNDN))
err ("subtraction 1 should be exact",
- s, x, y, p, r, trint, inexact);
+ s, x, y, p, (mp_rnd_t) r, trint, inexact);
sign_t = mpfr_cmp_ui (t, 0);
if (trint != 0 &&
(((inexact == 0) && (sign_t != 0)) ||
((inexact < 0) && (sign_t >= 0)) ||
((inexact > 0) && (sign_t <= 0))))
- err ("wrong inexact flag", s, x, y, p, r, trint, inexact);
+ err ("wrong inexact flag",
+ s, x, y, p, (mp_rnd_t) r, trint, inexact);
if (inexact == 0)
continue; /* end of the test for exact results */
@@ -275,31 +293,33 @@ main (int argc, char *argv[])
((r == GMP_RNDU || (r == GMP_RNDZ && MPFR_SIGN (x) < 0))
&& inexact < 0))
err ("wrong rounding direction",
- s, x, y, p, r, trint, inexact);
+ s, x, y, p, (mp_rnd_t) r, trint, inexact);
if (inexact < 0)
{
mpfr_add_ui (v, y, 1, GMP_RNDU);
if (mpfr_cmp (v, x) <= 0)
err ("representable integer between x and its "
- "rounded value", s, x, y, p, r, trint, inexact);
+ "rounded value",
+ s, x, y, p, (mp_rnd_t) r, trint, inexact);
}
else
{
mpfr_sub_ui (v, y, 1, GMP_RNDD);
if (mpfr_cmp (v, x) >= 0)
err ("representable integer between x and its "
- "rounded value", s, x, y, p, r, trint, inexact);
+ "rounded value",
+ s, x, y, p, (mp_rnd_t) r, trint, inexact);
}
if (r == GMP_RNDN)
{
int cmp;
if (mpfr_sub (u, v, x, GMP_RNDN))
err ("subtraction 2 should be exact",
- s, x, y, p, r, trint, inexact);
+ s, x, y, p, (mp_rnd_t) r, trint, inexact);
cmp = mpfr_cmp_abs (t, u);
if (cmp > 0)
err ("faithful rounding, but not the nearest integer",
- s, x, y, p, r, trint, inexact);
+ s, x, y, p, (mp_rnd_t) r, trint, inexact);
if (cmp < 0)
continue;
/* |t| = |u|: x is the middle of two consecutive
@@ -311,7 +331,8 @@ main (int argc, char *argv[])
mpfr_div_2ui (y, y, 1, GMP_RNDZ);
if (!mpfr_integer_p (y))
err ("halfway case for mpfr_rint, result isn't an"
- " even integer", s, x, y, p, r, trint, inexact);
+ " even integer",
+ s, x, y, p, (mp_rnd_t) r, trint, inexact);
/* If floor(x) and ceil(x) aren't both representable
integers, the mantissa must be even. */
mpfr_sub (v, v, y, GMP_RNDN);
@@ -322,7 +343,8 @@ main (int argc, char *argv[])
+ 1, GMP_RNDN);
if (!mpfr_integer_p (y))
err ("halfway case for mpfr_rint, mantissa isn't"
- " even", s, x, y, p, r, trint, inexact);
+ " even", s, x, y, p, (mp_rnd_t) r, trint,
+ inexact);
}
}
else
@@ -331,7 +353,8 @@ main (int argc, char *argv[])
if ((MPFR_SIGN (x) > 0 && inexact < 0) ||
(MPFR_SIGN (x) < 0 && inexact > 0))
err ("halfway case for mpfr_round, bad rounding"
- " direction", s, x, y, p, r, trint, inexact);
+ " direction",
+ s, x, y, p, (mp_rnd_t) r, trint, inexact);
}
}
}
diff --git a/tests/tround_prec.c b/tests/tround_prec.c
index b7e07c0fa..8073e59b0 100644
--- a/tests/tround_prec.c
+++ b/tests/tround_prec.c
@@ -56,12 +56,12 @@ main (void)
MPFR_ASSERTN(mpfr_cmp_ui (x, 0) == 0 && MPFR_IS_NEG(x));
emax = mpfr_get_emax ();
- mpfr_set_emax (0);
+ set_emax (0);
mpfr_set_prec (x, 3);
mpfr_set_str_binary (x, "0.111");
mpfr_prec_round (x, 2, GMP_RNDN);
MPFR_ASSERTN(mpfr_inf_p (x) && mpfr_sgn (x) > 0);
- mpfr_set_emax (emax);
+ set_emax (emax);
mpfr_set_prec (x, mp_bits_per_limb + 2);
mpfr_set_ui (x, 1, GMP_RNDN);
diff --git a/tests/tset.c b/tests/tset.c
index 04411a3d1..e8c6aa408 100644
--- a/tests/tset.c
+++ b/tests/tset.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_set.
-Copyright 2001, 2002, 2003, 2004 Free Software Foundation.
+Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation.
This file is part of the MPFR Library.
@@ -46,7 +46,7 @@ main (void)
{
mp_prec_t p, q;
mpfr_t x, y, z, u;
- mp_rnd_t rnd;
+ int rnd;
int inexact, cmp;
mp_exp_t emax;
@@ -80,13 +80,13 @@ main (void)
MPFR_ASSERTN(mpfr_cmp_ui (y, 0) == 0 && MPFR_IS_NEG(y));
emax = mpfr_get_emax ();
- mpfr_set_emax (0);
+ set_emax (0);
mpfr_set_prec (x, 3);
mpfr_set_str_binary (x, "0.111");
mpfr_set_prec (y, 2);
mpfr_set (y, x, GMP_RNDU);
MPFR_ASSERTN(mpfr_inf_p (y) && mpfr_sgn (y) > 0);
- mpfr_set_emax (emax);
+ set_emax (emax);
mpfr_set_prec (y, 11);
mpfr_set_str_binary (y, "0.11111111100E-8");
@@ -110,7 +110,7 @@ main (void)
mpfr_set_prec (y, q);
for (rnd = 0; rnd < GMP_RND_MAX; rnd++)
{
- inexact = mpfr_set (y, x, rnd);
+ inexact = mpfr_set (y, x, (mp_rnd_t) rnd);
cmp = mpfr_cmp (y, x);
if (((inexact == 0) && (cmp != 0)) ||
((inexact > 0) && (cmp <= 0)) ||
diff --git a/tests/tset_d.c b/tests/tset_d.c
index 0f096e30a..964a95036 100644
--- a/tests/tset_d.c
+++ b/tests/tset_d.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_set_d and mpfr_get_d.
-Copyright 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -108,16 +108,17 @@ main (int argc, char *argv[])
exit (1);
}
- mpfr_init2(z, 32);
- mpfr_set_d(z, 1.0, 0);
+ mpfr_init2 (z, 32);
+ mpfr_set_d (z, 1.0, (mp_rnd_t) 0);
if (mpfr_cmp_ui (z, 1))
{
mpfr_print_binary (z); puts ("");
printf ("Error: 1.0 != 1.0\n");
exit (1);
}
- mpfr_set_prec(x, 53); mpfr_init2(y, 53);
- mpfr_set_d(x, d=-1.08007920352320089721e+150, 0);
+ mpfr_set_prec (x, 53);
+ mpfr_init2 (y, 53);
+ mpfr_set_d (x, d=-1.08007920352320089721e+150, (mp_rnd_t) 0);
if (mpfr_get_d1 (x) != d)
{
mpfr_print_binary (x); puts ("");
@@ -126,9 +127,9 @@ main (int argc, char *argv[])
exit (1);
}
- mpfr_set_d(x, 8.06294740693074521573e-310, 0);
+ mpfr_set_d (x, 8.06294740693074521573e-310, (mp_rnd_t) 0);
d = -6.72658901114033715233e-165;
- mpfr_set_d(x, d, 0);
+ mpfr_set_d (x, d, (mp_rnd_t) 0);
if (d != mpfr_get_d1 (x))
{
mpfr_print_binary (x);
@@ -149,7 +150,7 @@ main (int argc, char *argv[])
#else
while (ABS(d) < DBL_MIN);
#endif
- mpfr_set_d (x, d, 0);
+ mpfr_set_d (x, d, (mp_rnd_t) 0);
dd = mpfr_get_d1 (x);
if (d != dd && !(Isnan(d) && Isnan(dd)))
{
diff --git a/tests/tset_exp.c b/tests/tset_exp.c
index 27381345a..9e29206f2 100644
--- a/tests/tset_exp.c
+++ b/tests/tset_exp.c
@@ -38,11 +38,11 @@ main (int argc, char *argv[])
ret = mpfr_set_exp (x, 2);
MPFR_ASSERTN(ret == 0 && mpfr_cmp_ui (x, 2) == 0);
- mpfr_set_emin (-1);
+ set_emin (-1);
ret = mpfr_set_exp (x, -1);
MPFR_ASSERTN(ret == 0 && mpfr_cmp_ui_2exp (x, 1, -2) == 0);
- mpfr_set_emax (1);
+ set_emax (1);
ret = mpfr_set_exp (x, 1);
MPFR_ASSERTN(ret == 0 && mpfr_cmp_ui (x, 1) == 0);
diff --git a/tests/tset_f.c b/tests/tset_f.c
index a92a47003..32f266cad 100644
--- a/tests/tset_f.c
+++ b/tests/tset_f.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_set_f.
-Copyright 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+Copyright 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -47,7 +47,7 @@ main (void)
mpfr_set_f (x, y, GMP_RNDN);
mpf_random2 (y, 10, 0);
- mpfr_set_f (x, y, RND_RAND() );
+ mpfr_set_f (x, y, (mp_rnd_t) RND_RAND());
/* bug found by Jean-Pierre Merlet */
mpfr_set_prec (x, 256);
@@ -93,25 +93,25 @@ main (void)
mpf_set_prec (z, pr);
mpf_random2 (z, z->_mp_prec, 0);
mpfr_set_prec (x, pr);
- mpfr_set_f (x, z, 0);
+ mpfr_set_f (x, z, (mp_rnd_t) 0);
}
/* Check for +0 */
mpfr_set_prec (x, 53);
mpf_set_prec (y, 53);
mpf_set_ui (y, 0);
- for(r = 0 ; r < GMP_RND_MAX ; r++)
+ for (r = 0 ; r < GMP_RND_MAX ; r++)
{
int i;
for (i = -1; i <= 1; i++)
{
if (i)
mpfr_set_si (x, i, GMP_RNDN);
- inexact = mpfr_set_f (x, y, r);
+ inexact = mpfr_set_f (x, y, (mp_rnd_t) r);
if (!MPFR_IS_ZERO(x) || !MPFR_IS_POS(x) || inexact)
{
printf ("mpfr_set_f(x,0) failed for %s, i = %d\n",
- mpfr_print_rnd_mode (r), i);
+ mpfr_print_rnd_mode ((mp_rnd_t) r), i);
exit (1);
}
}
diff --git a/tests/tset_ld.c b/tests/tset_ld.c
index dbf806b0b..92a5d810c 100644
--- a/tests/tset_ld.c
+++ b/tests/tset_ld.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_set_ld and mpfr_get_ld.
-Copyright 2002, 2003, 2004 Free Software Foundation, Inc.
+Copyright 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -57,13 +57,13 @@ Isnan_ld (long double d)
static void
check_set_get (long double d, mpfr_t x)
{
- mp_rnd_t r;
+ int r;
long double e;
int inex;
for (r = 0; r < GMP_RND_MAX; r++)
{
- inex = mpfr_set_ld (x, d, r);
+ inex = mpfr_set_ld (x, d, (mp_rnd_t) r);
if (inex != 0)
{
printf ("Error: mpfr_set_ld should be exact\n");
@@ -72,7 +72,7 @@ check_set_get (long double d, mpfr_t x)
mpfr_dump (x);
exit (1);
}
- e = mpfr_get_ld (x, r);
+ e = mpfr_get_ld (x, (mp_rnd_t) r);
if (e != d && !(Isnan_ld(e) && Isnan_ld(d)))
{
printf ("Error: mpfr_get_ld o mpfr_set_ld <> Id\n");
@@ -172,14 +172,14 @@ main (int argc, char *argv[])
/* check with reduced emax to exercise overflow */
emax = mpfr_get_emax ();
mpfr_set_prec (x, 2);
- mpfr_set_emax (1);
+ set_emax (1);
mpfr_set_ld (x, (long double) 2.0, GMP_RNDN);
MPFR_ASSERTN(mpfr_inf_p (x) && mpfr_sgn (x) > 0);
for (d = (long double) 2.0, i = 0; i < 13; i++, d *= d);
/* now d = 2^8192 */
mpfr_set_ld (x, d, GMP_RNDN);
MPFR_ASSERTN(mpfr_inf_p (x) && mpfr_sgn (x) > 0);
- mpfr_set_emax (emax);
+ set_emax (emax);
mpfr_clear (x);
diff --git a/tests/tset_q.c b/tests/tset_q.c
index 6dc01bb77..70d74f3af 100644
--- a/tests/tset_q.c
+++ b/tests/tset_q.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_set_q.
-Copyright 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+Copyright 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -75,24 +75,24 @@ static void check0(void)
mpq_t y;
mpfr_t x;
int inexact;
- mp_rnd_t r;
+ int r;
/* Check for +0 */
- mpfr_init(x);
- mpq_init(y);
- mpq_set_si(y, 0, 1);
- for(r = 0 ; r < GMP_RND_MAX ; r++)
+ mpfr_init (x);
+ mpq_init (y);
+ mpq_set_si (y, 0, 1);
+ for (r = 0; r < GMP_RND_MAX; r++)
{
- inexact = mpfr_set_q(x, y, r);
+ inexact = mpfr_set_q(x, y, (mp_rnd_t) r);
if (!MPFR_IS_ZERO(x) || !MPFR_IS_POS(x) || inexact)
{
printf("mpfr_set_q(x,0) failed for %s\n",
- mpfr_print_rnd_mode(r));
+ mpfr_print_rnd_mode ((mp_rnd_t) r));
exit(1);
}
}
- mpfr_clear(x);
- mpq_clear(y);
+ mpfr_clear (x);
+ mpq_clear (y);
}
int
diff --git a/tests/tset_si.c b/tests/tset_si.c
index 9f4771283..e08366ce0 100644
--- a/tests/tset_si.c
+++ b/tests/tset_si.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_set_si and mpfr_set_ui.
-Copyright 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+Copyright 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -72,7 +72,7 @@ main (int argc, char *argv[])
long k, z, d, N;
unsigned long zl, dl;
int inex;
- mp_rnd_t r;
+ int r;
mp_exp_t emax;
tests_start_mpfr ();
@@ -167,40 +167,40 @@ main (int argc, char *argv[])
exit (1);
}
- for(r = 0 ; r < GMP_RND_MAX ; r++)
+ for (r = 0 ; r < GMP_RND_MAX ; r++)
{
- mpfr_set_si (x, -1, r);
- mpfr_set_ui (x, 0, r);
+ mpfr_set_si (x, -1, (mp_rnd_t) r);
+ mpfr_set_ui (x, 0, (mp_rnd_t) r);
if (MPFR_IS_NEG (x) )
{
printf ("mpfr_set_ui (x, 0) gives -0 for %s\n",
- mpfr_print_rnd_mode(r));
+ mpfr_print_rnd_mode ((mp_rnd_t) r));
exit (1);
}
- mpfr_set_si (x, -1, r);
- mpfr_set_si (x, 0, r);
- if (MPFR_IS_NEG (x) )
+ mpfr_set_si (x, -1, (mp_rnd_t) r);
+ mpfr_set_si (x, 0, (mp_rnd_t) r);
+ if (MPFR_IS_NEG (x))
{
printf ("mpfr_set_si (x, 0) gives -0 for %s\n",
- mpfr_print_rnd_mode(r) );
+ mpfr_print_rnd_mode ((mp_rnd_t) r));
exit (1);
}
}
/* check potential bug in case mp_limb_t is unsigned */
emax = mpfr_get_emax ();
- mpfr_set_emax (0);
+ set_emax (0);
mpfr_set_si (x, -1, GMP_RNDN);
if (mpfr_sgn (x) >= 0)
{
printf ("mpfr_set_si (x, -1) fails\n");
exit (1);
}
- mpfr_set_emax (emax);
+ set_emax (emax);
emax = mpfr_get_emax ();
- mpfr_set_emax (5);
+ set_emax (5);
mpfr_set_prec (x, 2);
mpfr_set_si (x, -31, GMP_RNDN);
if (mpfr_sgn (x) >= 0)
@@ -208,7 +208,7 @@ main (int argc, char *argv[])
printf ("mpfr_set_si (x, -31) fails\n");
exit (1);
}
- mpfr_set_emax (emax);
+ set_emax (emax);
/* test for get_ui */
mpfr_set_ui (x, 0, GMP_RNDN);
@@ -244,13 +244,13 @@ main (int argc, char *argv[])
mpfr_set_ui (x, 7, GMP_RNDU);
MPFR_ASSERTN(mpfr_cmp_ui (x, 8) == 0);
emax = mpfr_get_emax ();
- mpfr_set_emax (3);
+ set_emax (3);
mpfr_set_ui (x, 7, GMP_RNDU);
MPFR_ASSERTN(mpfr_inf_p (x) && mpfr_sgn (x) > 0);
- mpfr_set_emax (1);
+ set_emax (1);
MPFR_ASSERTN( mpfr_set_ui (x, 7, GMP_RNDU) );
MPFR_ASSERTN(mpfr_inf_p (x) && mpfr_sgn (x) > 0);
- mpfr_set_emax (emax);
+ set_emax (emax);
/* Test for ERANGE flag + correct behaviour if overflow */
mpfr_set_prec (x, 256);
diff --git a/tests/tset_str.c b/tests/tset_str.c
index 52beb6982..7867ca68b 100644
--- a/tests/tset_str.c
+++ b/tests/tset_str.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_set_str.
-Copyright 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+Copyright 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -29,6 +29,21 @@ MA 02111-1307, USA. */
#define N 30000
+#define CHECK53(y, s, r, x, t, n) \
+ mpfr_set_str (y, s, 10, r); \
+ mpfr_set_str_binary (x, t); \
+ if (mpfr_cmp (x, y)) \
+ { \
+ printf ("Error in mpfr_set_str (%u):\n", n); \
+ mpfr_print_binary (x); \
+ puts (""); \
+ mpfr_print_binary (y); \
+ puts (""); \
+ mpfr_clear (x); \
+ mpfr_clear (y); \
+ exit (1); \
+ }
+
static void
check_underflow (void)
{
@@ -40,9 +55,9 @@ check_underflow (void)
/* Check underflow */
emin = mpfr_get_emin ();
- mpfr_set_emin (-20);
+ set_emin (-20);
res = mpfr_set_str (a, "0.00000000001", 10, GMP_RNDZ);
- if (!MPFR_IS_ZERO (a) || res == 0)
+ if (!MPFR_IS_ZERO (a))
{
printf("ERROR for mpfr_set_str (a, \"0.00000000001\", 10, GMP_RNDN)\n"
" with emin=-20\n"
@@ -50,18 +65,18 @@ check_underflow (void)
mpfr_dump (a);
exit (1);
}
- mpfr_set_emin (emin);
+ set_emin (emin);
/* check overflow */
emax = mpfr_get_emax ();
- mpfr_set_emax (1073741823); /* 2^30-1 */
+ set_emax (1073741823); /* 2^30-1 */
mpfr_set_str (a, "2E1000000000", 10, GMP_RNDN);
if (!mpfr_inf_p (a) || mpfr_sgn (a) < 0)
{
printf("ERROR for mpfr_set_str (a, \"2E1000000000\", 10, GMP_RNDN);\n");
exit (1);
}
- mpfr_set_emax (emax);
+ set_emax (emax);
mpfr_clear (a);
}
@@ -96,10 +111,9 @@ main (int argc, char *argv[])
bd = randlimb () & 8;
- str2 = str = (*__gmp_allocate_func) (nc * sizeof(char));
+ str2 = str = (char*) (*__gmp_allocate_func) (nc * sizeof(char));
if (bd)
-
{
for(k = 1; k <= bd; k++)
*(str2++) = (randlimb () & 1) + '0';
@@ -197,13 +211,13 @@ main (int argc, char *argv[])
baseprec = prec;
else
baseprec = 1 + (prec - 2 + logbase) / logbase;
- str = mpfr_get_str (NULL, &e, base, baseprec, x, k);
- mpfr_set_str (y, str, base, k);
+ str = mpfr_get_str (NULL, &e, base, baseprec, x, (mp_rnd_t) k);
+ mpfr_set_str (y, str, base, (mp_rnd_t) k);
MPFR_EXP(y) += logbase * (e - strlen (str));
if (mpfr_cmp (x, y))
{
printf ("mpfr_set_str o mpfr_get_str <> id for rnd_mode=%s\n",
- mpfr_print_rnd_mode (k));
+ mpfr_print_rnd_mode ((mp_rnd_t) k));
printf ("x=");
mpfr_print_binary (x);
puts ("");
@@ -220,13 +234,14 @@ main (int argc, char *argv[])
for (i = 2; i <= 36; i++)
{
- if (mpfr_set_str (x, "@NaN@garbage", i, GMP_RNDN) != 0 ||
+ if (mpfr_set_str (x, "@NaN@(garbage)", i, GMP_RNDN) != 0 ||
!mpfr_nan_p(x))
{
- printf ("mpfr_set_str failed on @NaN@garbage\n");
+ printf ("mpfr_set_str failed on @NaN@(garbage)\n");
exit (1);
}
+ /*
if (mpfr_set_str (x, "@Inf@garbage", i, GMP_RNDN) != 0 ||
!mpfr_inf_p(x) || MPFR_SIGN(x) < 0)
{
@@ -247,6 +262,7 @@ main (int argc, char *argv[])
printf ("mpfr_set_str failed on +@Inf@garbage\n");
exit (1);
}
+ */
if (i > 16)
continue;
@@ -406,6 +422,311 @@ main (int argc, char *argv[])
exit (1);
}
+ /* worst cases for rounding to nearest in double precision */
+ mpfr_set_prec (x, 53);
+ mpfr_set_prec (y, 53);
+
+ mpfr_set_str (y, "5e125", 10, GMP_RNDN);
+ mpfr_set_str_binary (x, "0.10111101000101110110011000100000101001010000000111111E418");
+ if (mpfr_cmp (x, y))
+ {
+ printf ("Error in mpfr_set_str (8):\n");
+ mpfr_print_binary (x);
+ puts ("");
+ mpfr_print_binary (y);
+ puts ("");
+ mpfr_clear (x);
+ mpfr_clear (y);
+ exit (1);
+ }
+
+ mpfr_set_str (y, "69e267", 10, GMP_RNDN);
+ mpfr_set_str_binary (x, "0.10000101101111100101101100000110010011001010011011010E894");
+ if (mpfr_cmp (x, y))
+ {
+ printf ("Error in mpfr_set_str (9):\n");
+ mpfr_print_binary (x);
+ puts ("");
+ mpfr_print_binary (y);
+ puts ("");
+ mpfr_clear (x);
+ mpfr_clear (y);
+ exit (1);
+ }
+
+ mpfr_set_str (y, "623e100", 10, GMP_RNDN);
+ mpfr_set_str_binary (x, "0.10110010000001010011000101111001110101000001111011111E342");
+ if (mpfr_cmp (x, y))
+ {
+ printf ("Error in mpfr_set_str (10):\n");
+ mpfr_print_binary (x);
+ puts ("");
+ mpfr_print_binary (y);
+ puts ("");
+ mpfr_clear (x);
+ mpfr_clear (y);
+ exit (1);
+ }
+
+ mpfr_set_str (y, "3571e263", 10, GMP_RNDN);
+ mpfr_set_str_binary (x, "0.10110001001100100010011000110000111010100000110101010E886");
+ if (mpfr_cmp (x, y))
+ {
+ printf ("Error in mpfr_set_str (11):\n");
+ mpfr_print_binary (x);
+ puts ("");
+ mpfr_print_binary (y);
+ puts ("");
+ mpfr_clear (x);
+ mpfr_clear (y);
+ exit (1);
+ }
+
+ mpfr_set_str (y, "75569e-254", 10, GMP_RNDN);
+ mpfr_set_str_binary (x, "0.10101101001000110001011011001000111000110101010110011E-827");
+ if (mpfr_cmp (x, y))
+ {
+ printf ("Error in mpfr_set_str (12):\n");
+ mpfr_print_binary (x);
+ puts ("");
+ mpfr_print_binary (y);
+ puts ("");
+ mpfr_clear (x);
+ mpfr_clear (y);
+ exit (1);
+ }
+
+ mpfr_set_str (y, "920657e-23", 10, GMP_RNDN);
+ mpfr_set_str_binary (x, "0.10101001110101001100110000101110110111101111001101100E-56");
+ if (mpfr_cmp (x, y))
+ {
+ printf ("Error in mpfr_set_str (13):\n");
+ mpfr_print_binary (x);
+ puts ("");
+ mpfr_print_binary (y);
+ puts ("");
+ mpfr_clear (x);
+ mpfr_clear (y);
+ exit (1);
+ }
+
+ mpfr_set_str (y, "9210917e80", 10, GMP_RNDN);
+ mpfr_set_str_binary (x, "0.11101101000100011001000110100011111100110000000110010E289");
+ if (mpfr_cmp (x, y))
+ {
+ printf ("Error in mpfr_set_str (14):\n");
+ mpfr_print_binary (x);
+ puts ("");
+ mpfr_print_binary (y);
+ puts ("");
+ mpfr_clear (x);
+ mpfr_clear (y);
+ exit (1);
+ }
+
+ mpfr_set_str (y, "87575437e-309", 10, GMP_RNDN);
+ mpfr_set_str_binary (x, "0.11110000001110011001000000110000000100000010101101100E-1000");
+ if (mpfr_cmp (x, y))
+ {
+ printf ("Error in mpfr_set_str (15):\n");
+ mpfr_print_binary (x);
+ puts ("");
+ mpfr_print_binary (y);
+ puts ("");
+ mpfr_clear (x);
+ mpfr_clear (y);
+ exit (1);
+ }
+
+ mpfr_set_str (y, "245540327e122", 10, GMP_RNDN);
+ mpfr_set_str_binary (x, "0.10001101101100010001100011110000110001100010111001011E434");
+ if (mpfr_cmp (x, y))
+ {
+ printf ("Error in mpfr_set_str (16):\n");
+ mpfr_print_binary (x);
+ puts ("");
+ mpfr_print_binary (y);
+ puts ("");
+ mpfr_clear (x);
+ mpfr_clear (y);
+ exit (1);
+ }
+
+ mpfr_set_str (y, "491080654e122", 10, GMP_RNDN);
+ mpfr_set_str_binary (x, "0.10001101101100010001100011110000110001100010111001011E435");
+ if (mpfr_cmp (x, y))
+ {
+ printf ("Error in mpfr_set_str (17):\n");
+ mpfr_print_binary (x);
+ puts ("");
+ mpfr_print_binary (y);
+ puts ("");
+ mpfr_clear (x);
+ mpfr_clear (y);
+ exit (1);
+ }
+
+ mpfr_set_str (y, "83356057653e193", 10, GMP_RNDN);
+ mpfr_set_str_binary (x, "0.10101010001001110011011011010111011100010101000011000E678");
+ if (mpfr_cmp (x, y))
+ {
+ printf ("Error in mpfr_set_str (18):\n");
+ mpfr_print_binary (x);
+ puts ("");
+ mpfr_print_binary (y);
+ puts ("");
+ mpfr_clear (x);
+ mpfr_clear (y);
+ exit (1);
+ }
+
+ CHECK53(y, "83356057653e193", GMP_RNDN, x,
+ "0.10101010001001110011011011010111011100010101000011000E678",
+ 18);
+
+ CHECK53(y, "619534293513e124", GMP_RNDN, x,
+ "0.10001000011000010000000110000001111111110000011110001e452",
+ 19);
+
+ CHECK53(y, "3142213164987e-294", GMP_RNDN, x,
+ "0.11101001101000000100111011111101111001010001001101111e-935",
+ 20);
+
+ CHECK53(y, "36167929443327e-159", GMP_RNDN, x,
+ "0.11100111001110111110000101011001100110010100011111100e-483",
+ 21);
+
+ CHECK53(y, "904198236083175e-161", GMP_RNDN, x,
+ "0.11100111001110111110000101011001100110010100011111100e-485",
+ 22);
+
+ CHECK53(y, "3743626360493413e-165", GMP_RNDN, x,
+ "0.11000100000100011101001010111101011011011111011111001e-496",
+ 23);
+
+ CHECK53(y, "94080055902682397e-242", GMP_RNDN, x,
+ "0.10110010010011000000111100011100111100110011011001010e-747",
+ 24);
+
+ CHECK53(y, "7e-303", GMP_RNDD, x,
+ "0.10011001100111001000100110001110001000110111110001011e-1003",
+ 25);
+ CHECK53(y, "7e-303", GMP_RNDU, x,
+ "0.10011001100111001000100110001110001000110111110001100e-1003",
+ 26);
+
+ CHECK53(y, "93e-234", GMP_RNDD, x,
+ "0.10010011110110010111001001111001000010000000001110101E-770",
+ 27);
+ CHECK53(y, "93e-234", GMP_RNDU, x,
+ "0.10010011110110010111001001111001000010000000001110110E-770",
+ 28);
+
+ CHECK53(y, "755e174", GMP_RNDD, x,
+ "0.10111110110010011000110010011111101111000111111000101E588",
+ 29);
+ CHECK53(y, "755e174", GMP_RNDU, x,
+ "0.10111110110010011000110010011111101111000111111000110E588",
+ 30);
+
+ CHECK53(y, "8699e-276", GMP_RNDD, x,
+ "0.10010110100101101111100100100011011101100110100101100E-903",
+ 31);
+ CHECK53(y, "8699e-276", GMP_RNDU, x,
+ "0.10010110100101101111100100100011011101100110100101101E-903",
+ 32);
+
+ CHECK53(y, "82081e41", GMP_RNDD, x,
+ "0.10111000000010000010111011111001111010100011111001011E153",
+ 33);
+ CHECK53(y, "82081e41", GMP_RNDU, x,
+ "0.10111000000010000010111011111001111010100011111001100E153",
+ 34);
+
+ CHECK53(y, "584169e229", GMP_RNDD, x,
+ "0.11101011001010111000001011001110111000111100110101010E780",
+ 35);
+ CHECK53(y, "584169e229", GMP_RNDU, x,
+ "0.11101011001010111000001011001110111000111100110101011E780",
+ 36);
+
+ CHECK53(y, "5783893e-128", GMP_RNDD, x,
+ "0.10011000111100000110011110000101100111110011101110100E-402",
+ 37);
+ CHECK53(y, "5783893e-128", GMP_RNDU, x,
+ "0.10011000111100000110011110000101100111110011101110101E-402",
+ 38);
+
+ CHECK53(y, "87575437e-310", GMP_RNDD, x,
+ "0.11000000001011100000110011110011010000000010001010110E-1003",
+ 39);
+ CHECK53(y, "87575437e-310", GMP_RNDU, x,
+ "0.11000000001011100000110011110011010000000010001010111E-1003",
+ 40);
+
+ CHECK53(y, "245540327e121", GMP_RNDD, x,
+ "0.11100010101101001111010010110100011100000100101000100E430",
+ 41);
+ CHECK53(y, "245540327e121", GMP_RNDU, x,
+ "0.11100010101101001111010010110100011100000100101000101E430",
+ 42);
+
+ CHECK53(y, "9078555839e-109", GMP_RNDD, x,
+ "0.11111110001010111010110000110011100110001010011101101E-329",
+ 43);
+ CHECK53(y, "9078555839e-109", GMP_RNDU, x,
+ "0.11111110001010111010110000110011100110001010011101110E-329",
+ 44);
+
+ CHECK53(y, "42333842451e201", GMP_RNDD, x,
+ "0.10000000110001001101000100110110111110101011101011111E704",
+ 45);
+ CHECK53(y, "42333842451e201", GMP_RNDU, x,
+ "0.10000000110001001101000100110110111110101011101100000E704",
+ 46);
+
+ CHECK53(y, "778380362293e218", GMP_RNDD, x,
+ "0.11001101010111000001001100001100110010000001010010010E764",
+ 47);
+ CHECK53(y, "778380362293e218", GMP_RNDU, x,
+ "0.11001101010111000001001100001100110010000001010010011E764",
+ 48);
+
+ CHECK53(y, "7812878489261e-179", GMP_RNDD, x,
+ "0.10010011011011010111001111011101111101101101001110100E-551",
+ 49);
+ CHECK53(y, "7812878489261e-179", GMP_RNDU, x,
+ "0.10010011011011010111001111011101111101101101001110101E-551",
+ 50);
+
+ CHECK53(y, "77003665618895e-73", GMP_RNDD, x,
+ "0.11000101111110111111001111111101001101111000000101001E-196",
+ 51);
+ CHECK53(y, "77003665618895e-73", GMP_RNDU, x,
+ "0.11000101111110111111001111111101001101111000000101010E-196",
+ 52);
+
+ CHECK53(y, "834735494917063e-300", GMP_RNDD, x,
+ "0.11111110001101100001001101111100010011001110111010001E-947",
+ 53);
+ CHECK53(y, "834735494917063e-300", GMP_RNDU, x,
+ "0.11111110001101100001001101111100010011001110111010010E-947",
+ 54);
+
+ CHECK53(y, "6182410494241627e-119", GMP_RNDD, x,
+ "0.10001101110010110010001011000010001000101110100000111E-342",
+ 55);
+ CHECK53(y, "6182410494241627e-119", GMP_RNDU, x,
+ "0.10001101110010110010001011000010001000101110100001000E-342",
+ 56);
+
+ CHECK53(y, "26153245263757307e49", GMP_RNDD, x,
+ "0.10011110111100000000001011011110101100010000011011110E218",
+ 57);
+ CHECK53(y, "26153245263757307e49", GMP_RNDU, x,
+ "0.10011110111100000000001011011110101100010000011011111E218",
+ 58);
+
/* to check this problem : I convert limb (10--0 or 101--1) into base b
with more than mp_bits_per_limb digits,
so when convert into base 2 I should have
@@ -422,7 +743,7 @@ main (int argc, char *argv[])
mpfr_set_prec (x, mp_bits_per_limb); /* x and y have only one limb */
mpfr_set_prec (y, mp_bits_per_limb);
- str = (*__gmp_allocate_func) (N + 20);
+ str = (char*) (*__gmp_allocate_func) (N + 20);
mpfr_set_ui (x, 1, GMP_RNDN); /* ensures that x is not NaN or Inf */
for (; nb_digit < N; nb_digit *= 10)
@@ -486,26 +807,26 @@ main (int argc, char *argv[])
/* check invalid input */
mpfr_set_ui (x, 1, GMP_RNDN);
ret = mpfr_set_str (x, "1", 37, GMP_RNDN);
- MPFR_ASSERTN(mpfr_cmp_ui (x, 1) == 0 && ret == -1);
+ MPFR_ASSERTN (ret == -1);
ret = mpfr_set_str (x, "1E10toto", 10, GMP_RNDN);
- MPFR_ASSERTN(mpfr_cmp_ui (x, 1) == 0 && ret == -1);
+ MPFR_ASSERTN (ret == -1);
ret = mpfr_set_str (x, "1p10toto", 16, GMP_RNDN);
- MPFR_ASSERTN(mpfr_cmp_ui (x, 1) == 0 && ret == -1);
+ MPFR_ASSERTN (ret == -1);
ret = mpfr_set_str (x, "", 16, GMP_RNDN);
- MPFR_ASSERTN(mpfr_cmp_ui (x, 1) == 0 && ret == -1);
+ MPFR_ASSERTN (ret == -1);
ret = mpfr_set_str (x, "+", 16, GMP_RNDN);
- MPFR_ASSERTN(mpfr_cmp_ui (x, 1) == 0 && ret == -1);
+ MPFR_ASSERTN (ret == -1);
ret = mpfr_set_str (x, "-", 16, GMP_RNDN);
- MPFR_ASSERTN(mpfr_cmp_ui (x, 1) == 0 && ret == -1);
+ MPFR_ASSERTN (ret == -1);
ret = mpfr_set_str (x, "this_is_an_invalid_number_in_base_36", 36, GMP_RNDN);
- MPFR_ASSERTN(mpfr_cmp_ui (x, 1) == 0 && ret == -1);
+ MPFR_ASSERTN (ret == -1);
ret = mpfr_set_str (x, "1.2.3", 10, GMP_RNDN);
- MPFR_ASSERTN(mpfr_cmp_ui (x, 1) == 0 && ret == -1);
+ MPFR_ASSERTN (ret == -1);
mpfr_set_prec (x, 135);
ret = mpfr_set_str (x, "thisisavalidnumberinbase36", 36, GMP_RNDN);
mpfr_set_prec (y, 135);
mpfr_set_str (y, "23833565676460972739462619524519814462546", 10, GMP_RNDN);
- MPFR_ASSERTN(mpfr_cmp (x, y) == 0 && ret == 0);
+ MPFR_ASSERTN (mpfr_cmp (x, y) == 0 && ret == 0);
/* coverage test for set_str_binary */
mpfr_set_str_binary (x, "NaN");
diff --git a/tests/tset_z.c b/tests/tset_z.c
index f0f49f5fc..afdc971a6 100644
--- a/tests/tset_z.c
+++ b/tests/tset_z.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_set_z.
-Copyright 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+Copyright 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -31,17 +31,18 @@ static void check0(void)
mpz_t y;
mpfr_t x;
int inexact, r;
+
/* Check for +0 */
- mpfr_init(x);
- mpz_init(y);
- mpz_set_si(y, 0);
- for(r = 0 ; r < GMP_RND_MAX ; r++)
+ mpfr_init (x);
+ mpz_init (y);
+ mpz_set_si (y, 0);
+ for(r = 0; r < GMP_RND_MAX; r++)
{
- inexact = mpfr_set_z(x, y, r);
+ inexact = mpfr_set_z (x, y, (mp_rnd_t) r);
if (!MPFR_IS_ZERO(x) || !MPFR_IS_POS(x) || inexact)
{
printf("mpfr_set_z(x,0) failed for %s\n",
- mpfr_print_rnd_mode(r));
+ mpfr_print_rnd_mode ((mp_rnd_t) r));
exit(1);
}
}
@@ -94,27 +95,27 @@ check_large (void)
/* check overflow */
emax = mpfr_get_emax ();
- mpfr_set_emax (2);
+ set_emax (2);
mpz_set_str (z, "7", 10);
mpfr_set_z (x, z, GMP_RNDU);
MPFR_ASSERTN(mpfr_inf_p (x) && mpfr_sgn (x) > 0);
- mpfr_set_emax (3);
+ set_emax (3);
mpfr_set_prec (x, 2);
mpz_set_str (z, "7", 10);
mpfr_set_z (x, z, GMP_RNDU);
MPFR_ASSERTN(mpfr_inf_p (x) && mpfr_sgn (x) > 0);
- mpfr_set_emax (emax);
+ set_emax (emax);
/* check underflow */
emin = mpfr_get_emin ();
- mpfr_set_emin (3);
+ set_emin (3);
mpz_set_str (z, "1", 10);
mpfr_set_z (x, z, GMP_RNDZ);
MPFR_ASSERTN(mpfr_cmp_ui (x, 0) == 0 && MPFR_IS_POS(x));
- mpfr_set_emin (2);
+ set_emin (2);
mpfr_set_z (x, z, GMP_RNDN);
MPFR_ASSERTN(mpfr_cmp_ui (x, 0) == 0 && MPFR_IS_POS(x));
- mpfr_set_emin (emin);
+ set_emin (emin);
mpz_clear (z);
mpfr_clear (x);
@@ -129,11 +130,12 @@ main (int argc, char *argv[])
tests_start_mpfr ();
check_large ();
- check (0, 0);
+ check (0, (mp_rnd_t) 0);
for (j = 0; j < 200000; j++)
- check (randlimb () & LONG_MAX, RND_RAND () );
- check0();
+ check (randlimb () & LONG_MAX, (mp_rnd_t) RND_RAND ());
+ check0 ();
tests_end_mpfr ();
+
return 0;
}
diff --git a/tests/tsqr.c b/tests/tsqr.c
index 037844503..a768143b9 100644
--- a/tests/tsqr.c
+++ b/tests/tsqr.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_sqr.
-Copyright 2004 Free Software Foundation.
+Copyright 2004, 2005 Free Software Foundation.
This file is part of the MPFR Library.
@@ -66,7 +66,7 @@ error2 (mp_rnd_t rnd, mpfr_prec_t prec, mpfr_t in, mpfr_t out,
void check_random(mpfr_prec_t p)
{
mpfr_t x,y,z;
- mp_rnd_t r;
+ int r;
int i, inexact1, inexact2;
mpfr_inits2(p, x, y, z, NULL);
@@ -74,14 +74,14 @@ void check_random(mpfr_prec_t p)
{
mpfr_random (x);
if (MPFR_IS_PURE_FP(x))
- for(r = 0 ; r < GMP_RND_MAX ; r++)
+ for (r = 0 ; r < GMP_RND_MAX ; r++)
{
- inexact1 = mpfr_mul (y, x, x, r);
- inexact2 = mpfr_sqr (z, x, r);
- if (mpfr_cmp(y, z))
- error1 (r,p,x,y,z);
+ inexact1 = mpfr_mul (y, x, x, (mp_rnd_t) r);
+ inexact2 = mpfr_sqr (z, x, (mp_rnd_t) r);
+ if (mpfr_cmp (y, z))
+ error1 ((mp_rnd_t) r,p,x,y,z);
if (inexact1 != inexact2)
- error2 (r,p,x,y,inexact1,inexact2);
+ error2 ((mp_rnd_t) r,p,x,y,inexact1,inexact2);
}
}
mpfr_clears(x,y,z,NULL);
diff --git a/tests/tsqrt.c b/tests/tsqrt.c
index 85a030ad0..cdbd5dc70 100644
--- a/tests/tsqrt.c
+++ b/tests/tsqrt.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_sqrt.
-Copyright 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+Copyright 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -304,7 +304,7 @@ check_inexact (mp_prec_t p)
mpfr_init2 (y, p);
mpfr_init2 (z, 2*p);
mpfr_random (x);
- rnd = RND_RAND();
+ rnd = (mp_rnd_t) RND_RAND();
inexact = mpfr_sqrt (y, x, rnd);
if (mpfr_mul (z, y, y, rnd)) /* exact since prec(z) = 2*prec(y) */
{
diff --git a/tests/tstrtofr.c b/tests/tstrtofr.c
index 29cad883b..f88542ed6 100644
--- a/tests/tstrtofr.c
+++ b/tests/tstrtofr.c
@@ -142,6 +142,7 @@ check_special (void)
}
/* Check base 62 */
+#if 0
res = mpfr_strtofr (x, "A", NULL, 62, GMP_RNDN);
if (res != 0 || mpfr_cmp_ui (x, 10))
{
@@ -174,6 +175,7 @@ check_special (void)
putchar ('\n');
exit (1);
}
+#endif
mpfr_clear (x);
mpfr_clear (y);
diff --git a/tests/tsub.c b/tests/tsub.c
index 9d5430beb..bdf14e00a 100644
--- a/tests/tsub.c
+++ b/tests/tsub.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_sub.
-Copyright 2001, 2002, 2003, 2004 Free Software Foundation.
+Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation.
This file is part of the MPFR Library.
@@ -411,14 +411,14 @@ check_inexact (void)
: MPFR_EXP(u) - MPFR_EXP(x);
pz = pz + MAX(MPFR_PREC(x), MPFR_PREC(u));
mpfr_set_prec (z, pz);
- rnd = RND_RAND();
+ rnd = (mp_rnd_t) RND_RAND();
if (mpfr_sub (z, x, u, rnd))
{
printf ("z <- x - u should be exact\n");
exit (1);
}
{
- rnd = RND_RAND ();
+ rnd = (mp_rnd_t) RND_RAND ();
inexact = mpfr_sub (y, x, u, rnd);
cmp = mpfr_cmp (y, z);
if (((inexact == 0) && (cmp != 0)) ||
diff --git a/tests/tsub1sp.c b/tests/tsub1sp.c
index 3983a9f6a..3f92a87c9 100644
--- a/tests/tsub1sp.c
+++ b/tests/tsub1sp.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_sub1sp.
-Copyright 2003, 2004 Free Software Foundation.
+Copyright 2003, 2004, 2005 Free Software Foundation.
This file is part of the MPFR Library.
@@ -34,7 +34,7 @@ int main(void)
tests_start_mpfr ();
check_special ();
- for(p = 2 ; p < 200 ; p++)
+ for (p = 2 ; p < 200 ; p++)
check_random (p);
tests_end_mpfr ();
@@ -44,49 +44,49 @@ int main(void)
#define STD_ERROR \
{\
printf("ERROR: for %s and p=%lu and i=%d:\nY=",\
- mpfr_print_rnd_mode(r), p, i);\
- mpfr_print_binary(y);\
- printf("\nZ="); mpfr_print_binary(z);\
- printf("\nReal: "); mpfr_print_binary(x2);\
- printf("\nGot : "); mpfr_print_binary(x);\
- putchar('\n');\
+ mpfr_print_rnd_mode ((mp_rnd_t) r), p, i);\
+ mpfr_print_binary(y);\
+ printf("\nZ="); mpfr_print_binary(z);\
+ printf("\nReal: "); mpfr_print_binary(x2);\
+ printf("\nGot : "); mpfr_print_binary(x);\
+ putchar('\n');\
exit(1);\
}
#define STD_ERROR2 \
{\
printf("ERROR: for %s and p=%lu and i=%d:\nY=",\
- mpfr_print_rnd_mode(r), p, i);\
+ mpfr_print_rnd_mode ((mp_rnd_t) r), p, i);\
mpfr_print_binary(y);\
printf("\nZ="); mpfr_print_binary(z);\
printf("\nR="); mpfr_print_binary(x);\
printf("\nWrong inexact flag. Real: %d. Got: %d\n", \
- inexact1, inexact2); \
+ inexact1, inexact2); \
exit(1);\
}
void check_random(mpfr_prec_t p)
{
mpfr_t x,y,z,x2;
- mp_rnd_t r;
+ int r;
int i, inexact1, inexact2;
mpfr_inits2(p, x,y,z,x2,NULL);
- for(i = 0 ; i < 500 ; i++)
+ for (i = 0 ; i < 500 ; i++)
{
mpfr_random (y);
mpfr_random (z);
if (MPFR_IS_PURE_FP(y) && MPFR_IS_PURE_FP(z))
- for(r = 0 ; r < GMP_RND_MAX ; r++)
- {
- inexact1 = mpfr_sub1(x2, y, z, r);
- inexact2 = mpfr_sub1sp(x, y, z, r);
- if (mpfr_cmp(x, x2))
- STD_ERROR;
- if (inexact1 != inexact2)
- STD_ERROR2;
- }
+ for(r = 0 ; r < GMP_RND_MAX ; r++)
+ {
+ inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r);
+ inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r);
+ if (mpfr_cmp(x, x2))
+ STD_ERROR;
+ if (inexact1 != inexact2)
+ STD_ERROR2;
+ }
}
mpfr_clears(x,y,z,x2,NULL);
@@ -95,14 +95,14 @@ void check_random(mpfr_prec_t p)
void check_special(void)
{
mpfr_t x,y,z,x2;
- mp_rnd_t r;
+ int r;
mpfr_prec_t p;
int i = -1, inexact1, inexact2;
mp_exp_t es;
mpfr_inits(x,y,z,x2,NULL);
- for(r = 0 ; r < GMP_RND_MAX ; r++)
+ for (r = 0 ; r < GMP_RND_MAX ; r++)
{
p = 53;
mpfr_set_prec(x, 53);
@@ -110,397 +110,396 @@ void check_special(void)
mpfr_set_prec(y, 53);
mpfr_set_prec(z, 53);
- mpfr_set_str_binary (y,
+ mpfr_set_str_binary (y,
"0.10110111101101110010010010011011000001101101011011001E31");
-
- mpfr_sub1sp(x, y, y, r);
+
+ mpfr_sub1sp (x, y, y, (mp_rnd_t) r);
if (mpfr_cmp_ui(x, 0))
- {
- printf("Error for x-x with p=%lu. Expected 0. Got:", p);
- mpfr_print_binary(x);
- exit(1);
- }
-
- mpfr_set(z, y, r);
- mpfr_sub1sp(x, y, z, r);
+ {
+ printf("Error for x-x with p=%lu. Expected 0. Got:", p);
+ mpfr_print_binary(x);
+ exit(1);
+ }
+
+ mpfr_set(z, y, (mp_rnd_t) r);
+ mpfr_sub1sp(x, y, z, (mp_rnd_t) r);
if (mpfr_cmp_ui(x, 0))
- {
- printf("Error for x-y with y=x and p=%lu. Expected 0. Got:", p);
- mpfr_print_binary(x);
- exit(1);
- }
+ {
+ printf("Error for x-y with y=x and p=%lu. Expected 0. Got:", p);
+ mpfr_print_binary(x);
+ exit(1);
+ }
/* diff = 0 */
mpfr_set_str_binary (y,
"0.10110111101101110010010010011011001001101101011011001E31");
- inexact1 = mpfr_sub1(x2, y, z, r);
- inexact2 = mpfr_sub1sp(x, y, z, r);
+ inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r);
+ inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r);
if (mpfr_cmp(x, x2))
- STD_ERROR;
+ STD_ERROR;
if (inexact1 != inexact2)
- STD_ERROR2;
-
+ STD_ERROR2;
+
/* Diff = 1 */
mpfr_set_str_binary (y,
"0.10110111101101110010010010011011000001101101011011001E30");
- inexact1 = mpfr_sub1(x2, y, z, r);
- inexact2 = mpfr_sub1sp(x, y, z, r);
+ inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r);
+ inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r);
if (mpfr_cmp(x, x2))
- STD_ERROR;
+ STD_ERROR;
if (inexact1 != inexact2)
- STD_ERROR2;
-
+ STD_ERROR2;
+
/* Diff = 2 */
mpfr_set_str_binary (y,
"0.10110111101101110010010010011011000101101101011011001E32");
- inexact1 = mpfr_sub1(x2, y, z, r);
- inexact2 = mpfr_sub1sp(x, y, z, r);
+ inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r);
+ inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r);
if (mpfr_cmp(x, x2))
- STD_ERROR;
+ STD_ERROR;
if (inexact1 != inexact2)
- STD_ERROR2;
-
+ STD_ERROR2;
+
/* Diff = 32 */
mpfr_set_str_binary (y,
"0.10110111101101110010010010011011000001101101011011001E63");
- inexact1 = mpfr_sub1(x2, y, z, r);
- inexact2 = mpfr_sub1sp(x, y, z, r);
+ inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r);
+ inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r);
if (mpfr_cmp(x, x2))
- STD_ERROR;
+ STD_ERROR;
if (inexact1 != inexact2)
- STD_ERROR2;
-
+ STD_ERROR2;
+
/* Diff = 52 */
mpfr_set_str_binary (y,
"0.10110111101101110010010010011011010001101101011011001E83");
- inexact1 = mpfr_sub1(x2, y, z, r);
- inexact2 = mpfr_sub1sp(x, y, z, r);
+ inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r);
+ inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r);
if (mpfr_cmp(x, x2))
- STD_ERROR;
+ STD_ERROR;
if (inexact1 != inexact2)
- STD_ERROR2;
-
+ STD_ERROR2;
+
/* Diff = 53 */
mpfr_set_str_binary (y,
"0.10110111101101110010010010011111000001101101011011001E31");
- inexact1 = mpfr_sub1(x2, y, z, r);
- inexact2 = mpfr_sub1sp(x, y, z, r);
+ inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r);
+ inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r);
if (mpfr_cmp(x, x2))
STD_ERROR;
if (inexact1 != inexact2)
- STD_ERROR2;
+ STD_ERROR2;
/* Diff > 200 */
mpfr_set_str_binary (y,
"0.10110111101101110010010010011011000001101101011011001E331");
- inexact1 = mpfr_sub1(x2, y, z, r);
- inexact2 = mpfr_sub1sp(x, y, z, r);
+ inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r);
+ inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r);
if (mpfr_cmp(x, x2))
- STD_ERROR;
+ STD_ERROR;
if (inexact1 != inexact2)
- STD_ERROR2;
+ STD_ERROR2;
- mpfr_set_str_binary (y,
+ mpfr_set_str_binary (y,
"0.10000000000000000000000000000000000000000000000000000E31");
- mpfr_set_str_binary (z,
+ mpfr_set_str_binary (z,
"0.11111111111111111111111111111111111111111111111111111E30");
- inexact1 = mpfr_sub1(x2, y, z, r);
- inexact2 = mpfr_sub1sp(x, y, z, r);
- if (mpfr_cmp(x, x2))
- STD_ERROR;
- if (inexact1 != inexact2)
- STD_ERROR2;
-
- mpfr_set_str_binary (y,
+ inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r);
+ inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r);
+ if (mpfr_cmp(x, x2))
+ STD_ERROR;
+ if (inexact1 != inexact2)
+ STD_ERROR2;
+
+ mpfr_set_str_binary (y,
"0.10000000000000000000000000000000000000000000000000000E31");
- mpfr_set_str_binary (z,
+ mpfr_set_str_binary (z,
"0.11111111111111111111111111111111111111111111111111111E29");
- inexact1 = mpfr_sub1(x2, y, z, r);
- inexact2 = mpfr_sub1sp(x, y, z, r);
- if (mpfr_cmp(x, x2))
- STD_ERROR;
- if (inexact1 != inexact2)
- STD_ERROR2;
-
- mpfr_set_str_binary (y,
+ inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r);
+ inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r);
+ if (mpfr_cmp(x, x2))
+ STD_ERROR;
+ if (inexact1 != inexact2)
+ STD_ERROR2;
+
+ mpfr_set_str_binary (y,
"0.10000000000000000000000000000000000000000000000000000E52");
- mpfr_set_str_binary (z,
+ mpfr_set_str_binary (z,
"0.10000000000010000000000000000000000000000000000000000E00");
- inexact1 = mpfr_sub1(x2, y, z, r);
- inexact2 = mpfr_sub1sp(x, y, z, r);
- if (mpfr_cmp(x, x2))
- STD_ERROR;
- if (inexact1 != inexact2)
- STD_ERROR2;
-
- mpfr_set_str_binary (y,
- "0.11100000000000000000000000000000000000000000000000000E53");
- mpfr_set_str_binary (z,
- "0.10000000000000000000000000000000000000000000000000000E00");
- inexact1 = mpfr_sub1(x2, y, z, r);
- inexact2 = mpfr_sub1sp(z, y, z, r);
- mpfr_set(x, z, r);
- if (mpfr_cmp(x, x2))
- STD_ERROR;
- if (inexact1 != inexact2)
- STD_ERROR2;
-
- mpfr_set_str_binary (y,
+ inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r);
+ inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r);
+ if (mpfr_cmp(x, x2))
+ STD_ERROR;
+ if (inexact1 != inexact2)
+ STD_ERROR2;
+
+ mpfr_set_str_binary (y,
+ "0.11100000000000000000000000000000000000000000000000000E53");
+ mpfr_set_str_binary (z,
+ "0.10000000000000000000000000000000000000000000000000000E00");
+ inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r);
+ inexact2 = mpfr_sub1sp(z, y, z, (mp_rnd_t) r);
+ mpfr_set(x, z, (mp_rnd_t) r);
+ if (mpfr_cmp(x, x2))
+ STD_ERROR;
+ if (inexact1 != inexact2)
+ STD_ERROR2;
+
+ mpfr_set_str_binary (y,
"0.10000000000000000000000000000000000000000000000000000E53");
- mpfr_set_str_binary (z,
+ mpfr_set_str_binary (z,
"0.10100000000000000000000000000000000000000000000000000E00");
- inexact1 = mpfr_sub1(x2, y, z, r);
- inexact2 = mpfr_sub1sp(x, y, z, r);
- if (mpfr_cmp(x, x2))
- STD_ERROR;
- if (inexact1 != inexact2)
- STD_ERROR2;
-
- mpfr_set_str_binary (y,
- "0.10000000000000000000000000000000000000000000000000000E54");
- mpfr_set_str_binary (z,
- "0.10100000000000000000000000000000000000000000000000000E00");
- inexact1 = mpfr_sub1(x2, y, z, r);
- inexact2 = mpfr_sub1sp(x, y, z, r);
- if (mpfr_cmp(x, x2))
- STD_ERROR;
- if (inexact1 != inexact2)
- STD_ERROR2;
-
- p = 63;
- mpfr_set_prec(x, p);
- mpfr_set_prec(x2, p);
- mpfr_set_prec(y, p);
- mpfr_set_prec(z, p);
- mpfr_set_str_binary (y,
+ inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r);
+ inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r);
+ if (mpfr_cmp(x, x2))
+ STD_ERROR;
+ if (inexact1 != inexact2)
+ STD_ERROR2;
+
+ mpfr_set_str_binary (y,
+ "0.10000000000000000000000000000000000000000000000000000E54");
+ mpfr_set_str_binary (z,
+ "0.10100000000000000000000000000000000000000000000000000E00");
+ inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r);
+ inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r);
+ if (mpfr_cmp(x, x2))
+ STD_ERROR;
+ if (inexact1 != inexact2)
+ STD_ERROR2;
+
+ p = 63;
+ mpfr_set_prec(x, p);
+ mpfr_set_prec(x2, p);
+ mpfr_set_prec(y, p);
+ mpfr_set_prec(z, p);
+ mpfr_set_str_binary (y,
"0.100000000000000000000000000000000000000000000000000000000000000E62");
- mpfr_set_str_binary (z,
+ mpfr_set_str_binary (z,
"0.110000000000000000000000000000000000000000000000000000000000000E00");
- inexact1 = mpfr_sub1(x2, y, z, r);
- inexact2 = mpfr_sub1sp(x, y, z, r);
- if (mpfr_cmp(x, x2))
- STD_ERROR;
- if (inexact1 != inexact2)
- STD_ERROR2;
-
- p = 64;
- mpfr_set_prec(x, 64);
- mpfr_set_prec(x2, 64);
- mpfr_set_prec(y, 64);
- mpfr_set_prec(z, 64);
-
- mpfr_set_str_binary (y,
+ inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r);
+ inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r);
+ if (mpfr_cmp(x, x2))
+ STD_ERROR;
+ if (inexact1 != inexact2)
+ STD_ERROR2;
+
+ p = 64;
+ mpfr_set_prec(x, 64);
+ mpfr_set_prec(x2, 64);
+ mpfr_set_prec(y, 64);
+ mpfr_set_prec(z, 64);
+
+ mpfr_set_str_binary (y,
"0.1100000000000000000000000000000000000000000000000000000000000000E31");
- mpfr_set_str_binary (z,
+ mpfr_set_str_binary (z,
"0.1111111111111111111111111110000000000000000000000000011111111111E29");
- inexact1 = mpfr_sub1(x2, y, z, r);
- inexact2 = mpfr_sub1sp(x, y, z, r);
- if (mpfr_cmp(x, x2))
- STD_ERROR;
- if (inexact1 != inexact2)
- STD_ERROR2;
-
- mpfr_set_str_binary (y,
+ inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r);
+ inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r);
+ if (mpfr_cmp(x, x2))
+ STD_ERROR;
+ if (inexact1 != inexact2)
+ STD_ERROR2;
+
+ mpfr_set_str_binary (y,
"0.1000000000000000000000000000000000000000000000000000000000000000E63");
- mpfr_set_str_binary (z,
+ mpfr_set_str_binary (z,
"0.1011000000000000000000000000000000000000000000000000000000000000E00");
- inexact1 = mpfr_sub1(x2, y, z, r);
- inexact2 = mpfr_sub1sp(x, y, z, r);
- if (mpfr_cmp(x, x2))
- STD_ERROR;
- if (inexact1 != inexact2)
- STD_ERROR2;
-
- mpfr_set_str_binary (y,
+ inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r);
+ inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r);
+ if (mpfr_cmp(x, x2))
+ STD_ERROR;
+ if (inexact1 != inexact2)
+ STD_ERROR2;
+
+ mpfr_set_str_binary (y,
"0.1000000000000000000000000000000000000000000000000000000000000000E63");
- mpfr_set_str_binary (z,
+ mpfr_set_str_binary (z,
"0.1110000000000000000000000000000000000000000000000000000000000000E00");
- inexact1 = mpfr_sub1(x2, y, z, r);
- inexact2 = mpfr_sub1sp(x, y, z, r);
- if (mpfr_cmp(x, x2))
- STD_ERROR;
- if (inexact1 != inexact2)
- STD_ERROR2;
-
- mpfr_set_str_binary (y,
+ inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r);
+ inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r);
+ if (mpfr_cmp(x, x2))
+ STD_ERROR;
+ if (inexact1 != inexact2)
+ STD_ERROR2;
+
+ mpfr_set_str_binary (y,
"0.10000000000000000000000000000000000000000000000000000000000000E63");
- mpfr_set_str_binary (z,
+ mpfr_set_str_binary (z,
"0.10000000000000000000000000000000000000000000000000000000000000E00");
- inexact1 = mpfr_sub1(x2, y, z, r);
- inexact2 = mpfr_sub1sp(x, y, z, r);
- if (mpfr_cmp(x, x2))
- STD_ERROR;
- if (inexact1 != inexact2)
- STD_ERROR2;
-
- mpfr_set_str_binary (y,
+ inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r);
+ inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r);
+ if (mpfr_cmp(x, x2))
+ STD_ERROR;
+ if (inexact1 != inexact2)
+ STD_ERROR2;
+
+ mpfr_set_str_binary (y,
"0.1000000000000000000000000000000000000000000000000000000000000000E64");
- mpfr_set_str_binary (z,
+ mpfr_set_str_binary (z,
"0.1010000000000000000000000000000000000000000000000000000000000000E00");
- inexact1 = mpfr_sub1(x2, y, z, r);
- inexact2 = mpfr_sub1sp(x, y, z, r);
- if (mpfr_cmp(x, x2))
- STD_ERROR;
- if (inexact1 != inexact2)
- STD_ERROR2;
-
- MPFR_SET_NAN(x);
- MPFR_SET_NAN(x2);
- mpfr_set_str_binary (y,
+ inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r);
+ inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r);
+ if (mpfr_cmp(x, x2))
+ STD_ERROR;
+ if (inexact1 != inexact2)
+ STD_ERROR2;
+
+ MPFR_SET_NAN(x);
+ MPFR_SET_NAN(x2);
+ mpfr_set_str_binary (y,
"0.1000000000000000000000000000000000000000000000000000000000000000"
- "E-1073741823");
- mpfr_set_str_binary (z,
+ "E-1073741823");
+ mpfr_set_str_binary (z,
"0.1100000000000000000000000000000000000000000000000000000000000000"
- "E-1073741823");
- inexact1 = mpfr_sub1(x2, y, z, r);
- inexact2 = mpfr_sub1sp(x, y, z, r);
- if (mpfr_cmp(x, x2))
- STD_ERROR;
- if (inexact1 != inexact2)
- STD_ERROR2;
-
- p = 9;
- mpfr_set_prec(x, p);
- mpfr_set_prec(x2, p);
- mpfr_set_prec(y, p);
- mpfr_set_prec(z, p);
-
- mpfr_set_str_binary (y, "0.100000000E1");
- mpfr_set_str_binary (z, "0.100000000E-8");
- inexact1 = mpfr_sub1(x2, y, z, r);
- inexact2 = mpfr_sub1sp(x, y, z, r);
- if (mpfr_cmp(x, x2))
- STD_ERROR;
- if (inexact1 != inexact2)
- STD_ERROR2;
-
- p = 34;
- mpfr_set_prec(x, p);
- mpfr_set_prec(x2, p);
- mpfr_set_prec(y, p);
- mpfr_set_prec(z, p);
-
- mpfr_set_str_binary (y, "-0.1011110000111100010111011100110100E-18");
- mpfr_set_str_binary (z, "0.1000101010110011010101011110000000E-14");
- inexact1 = mpfr_sub1(x2, y, z, r);
- inexact2 = mpfr_sub1sp(x, y, z, r);
- if (mpfr_cmp(x, x2))
- STD_ERROR;
- if (inexact1 != inexact2)
- STD_ERROR2;
-
- p = 124;
- mpfr_set_prec(x, p);
- mpfr_set_prec(x2, p);
- mpfr_set_prec(y, p);
- mpfr_set_prec(z, p);
-
- mpfr_set_str_binary (y,
+ "E-1073741823");
+ inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r);
+ inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r);
+ if (mpfr_cmp(x, x2))
+ STD_ERROR;
+ if (inexact1 != inexact2)
+ STD_ERROR2;
+
+ p = 9;
+ mpfr_set_prec(x, p);
+ mpfr_set_prec(x2, p);
+ mpfr_set_prec(y, p);
+ mpfr_set_prec(z, p);
+
+ mpfr_set_str_binary (y, "0.100000000E1");
+ mpfr_set_str_binary (z, "0.100000000E-8");
+ inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r);
+ inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r);
+ if (mpfr_cmp(x, x2))
+ STD_ERROR;
+ if (inexact1 != inexact2)
+ STD_ERROR2;
+
+ p = 34;
+ mpfr_set_prec(x, p);
+ mpfr_set_prec(x2, p);
+ mpfr_set_prec(y, p);
+ mpfr_set_prec(z, p);
+
+ mpfr_set_str_binary (y, "-0.1011110000111100010111011100110100E-18");
+ mpfr_set_str_binary (z, "0.1000101010110011010101011110000000E-14");
+ inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r);
+ inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r);
+ if (mpfr_cmp(x, x2))
+ STD_ERROR;
+ if (inexact1 != inexact2)
+ STD_ERROR2;
+
+ p = 124;
+ mpfr_set_prec(x, p);
+ mpfr_set_prec(x2, p);
+ mpfr_set_prec(y, p);
+ mpfr_set_prec(z, p);
+
+ mpfr_set_str_binary (y,
"0.1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E1");
- mpfr_set_str_binary (z,
+ mpfr_set_str_binary (z,
"0.1011111000100111000011001000011101010101101100101010101001000001110100001101110110001110111010000011101001100010111110001100E-31");
- inexact1 = mpfr_sub1(x2, y, z, r);
- inexact2 = mpfr_sub1sp(x, y, z, r);
- if (mpfr_cmp(x, x2))
- STD_ERROR;
- if (inexact1 != inexact2)
- STD_ERROR2;
-
- p = 288;
- mpfr_set_prec(x, p);
- mpfr_set_prec(x2, p);
- mpfr_set_prec(y, p);
- mpfr_set_prec(z, p);
-
- mpfr_set_str_binary (y,
+ inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r);
+ inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r);
+ if (mpfr_cmp(x, x2))
+ STD_ERROR;
+ if (inexact1 != inexact2)
+ STD_ERROR2;
+
+ p = 288;
+ mpfr_set_prec(x, p);
+ mpfr_set_prec(x2, p);
+ mpfr_set_prec(y, p);
+ mpfr_set_prec(z, p);
+
+ mpfr_set_str_binary (y,
"0.111000110011000001000111101010111011110011101001101111111110000011100101000001001010110010101010011001010100000001110011110001010101101010001011101110100100001011110100110000101101100011010001001011011010101010000010001101001000110010010111111011110001111101001000101101001100101100101000E80");
- mpfr_set_str_binary (z,
+ mpfr_set_str_binary (z,
"-0.100001111111101001011010001100110010100111001110000110011101001011010100001000000100111011010110110010000000000010101101011000010000110001110010100001100101011100100100001011000100011110000001010101000100011101001000010111100000111000111011001000100100011000100000010010111000000100100111E-258");
- inexact1 = mpfr_sub1(x2, y, z, r);
- inexact2 = mpfr_sub1sp(x, y, z, r);
- if (mpfr_cmp(x, x2))
- STD_ERROR;
- if (inexact1 != inexact2)
- STD_ERROR2;
-
- p = 85;
- mpfr_set_prec(x, p);
- mpfr_set_prec(x2, p);
- mpfr_set_prec(y, p);
- mpfr_set_prec(z, p);
-
- mpfr_set_str_binary (y,
+ inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r);
+ inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r);
+ if (mpfr_cmp(x, x2))
+ STD_ERROR;
+ if (inexact1 != inexact2)
+ STD_ERROR2;
+
+ p = 85;
+ mpfr_set_prec(x, p);
+ mpfr_set_prec(x2, p);
+ mpfr_set_prec(y, p);
+ mpfr_set_prec(z, p);
+
+ mpfr_set_str_binary (y,
"0.1111101110100110110110100010101011101001100010100011110110110010010011101100101111100E-4");
- mpfr_set_str_binary (z,
+ mpfr_set_str_binary (z,
"0.1111101110100110110110100010101001001000011000111000011101100101110100001110101010110E-4");
- inexact1 = mpfr_sub1(x2, y, z, r);
- inexact2 = mpfr_sub1sp(x, y, z, r);
- if (mpfr_cmp(x, x2))
- STD_ERROR;
- if (inexact1 != inexact2)
- STD_ERROR2;
-
- p = 64;
- mpfr_set_prec(x, p); mpfr_set_prec(x2, p);
- mpfr_set_prec(y, p); mpfr_set_prec(z, p);
-
- mpfr_set_str_binary (y,
- "0.11000000000000000000000000000000"
- "00000000000000000000000000000000E1");
- mpfr_set_str_binary (z,
- "0.10000000000000000000000000000000"
+ inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r);
+ inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r);
+ if (mpfr_cmp(x, x2))
+ STD_ERROR;
+ if (inexact1 != inexact2)
+ STD_ERROR2;
+
+ p = 64;
+ mpfr_set_prec(x, p); mpfr_set_prec(x2, p);
+ mpfr_set_prec(y, p); mpfr_set_prec(z, p);
+
+ mpfr_set_str_binary (y,
+ "0.11000000000000000000000000000000"
+ "00000000000000000000000000000000E1");
+ mpfr_set_str_binary (z,
+ "0.10000000000000000000000000000000"
"00000000000000000000000000000001E0");
- inexact1 = mpfr_sub1(x2, y, z, r);
- inexact2 = mpfr_sub1sp(x, y, z, r);
- if (mpfr_cmp(x, x2))
- STD_ERROR;
- if (inexact1 != inexact2)
- STD_ERROR2;
-
- mpfr_set_str_binary (y,
- "0.11000000000000000000000000000000"
+ inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r);
+ inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r);
+ if (mpfr_cmp(x, x2))
+ STD_ERROR;
+ if (inexact1 != inexact2)
+ STD_ERROR2;
+
+ mpfr_set_str_binary (y,
+ "0.11000000000000000000000000000000"
"000000000000000000000000000001E1");
- mpfr_set_str_binary (z,
- "0.10000000000000000000000000000000"
+ mpfr_set_str_binary (z,
+ "0.10000000000000000000000000000000"
"00000000000000000000000000000001E0");
- inexact1 = mpfr_sub1(x2, y, z, r);
- inexact2 = mpfr_sub1sp(x, y, z, r);
- if (mpfr_cmp(x, x2))
- STD_ERROR;
- if (inexact1 != inexact2)
- STD_ERROR2;
-
- es = mpfr_get_emin ();
- mpfr_set_emin (-1024);
-
- mpfr_set_str_binary (y,
- "0.10000000000000000000000000000000"
+ inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r);
+ inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r);
+ if (mpfr_cmp(x, x2))
+ STD_ERROR;
+ if (inexact1 != inexact2)
+ STD_ERROR2;
+
+ es = mpfr_get_emin ();
+ set_emin (-1024);
+
+ mpfr_set_str_binary (y,
+ "0.10000000000000000000000000000000"
"000000000000000000000000000000E-1023");
- mpfr_set_str_binary (z,
- "0.10000000000000000000000000000000"
+ mpfr_set_str_binary (z,
+ "0.10000000000000000000000000000000"
"00000000000000000000000000000001E-1023");
- inexact1 = mpfr_sub1(x2, y, z, r);
- inexact2 = mpfr_sub1sp(x, y, z, r);
- if (mpfr_cmp(x, x2))
- STD_ERROR;
- if (inexact1 != inexact2)
- STD_ERROR2;
-
- mpfr_set_str_binary (y,
- "0.10000000000000000000000000000000"
- "000000000000000000000000000000E-1023");
- mpfr_set_str_binary (z,
- "0.1000000000000000000000000000000"
- "000000000000000000000000000000E-1023");
- inexact1 = mpfr_sub1(x2, y, z, r);
- inexact2 = mpfr_sub1sp(x, y, z, r);
- if (mpfr_cmp(x, x2))
- STD_ERROR;
- if (inexact1 != inexact2)
- STD_ERROR2;
+ inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r);
+ inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r);
+ if (mpfr_cmp(x, x2))
+ STD_ERROR;
+ if (inexact1 != inexact2)
+ STD_ERROR2;
- mpfr_set_emin(es);
+ mpfr_set_str_binary (y,
+ "0.10000000000000000000000000000000"
+ "000000000000000000000000000000E-1023");
+ mpfr_set_str_binary (z,
+ "0.1000000000000000000000000000000"
+ "000000000000000000000000000000E-1023");
+ inexact1 = mpfr_sub1(x2, y, z, (mp_rnd_t) r);
+ inexact2 = mpfr_sub1sp(x, y, z, (mp_rnd_t) r);
+ if (mpfr_cmp(x, x2))
+ STD_ERROR;
+ if (inexact1 != inexact2)
+ STD_ERROR2;
+ set_emin (es);
}
- mpfr_clears(x,y,z,x2,NULL);
+ mpfr_clears(x,y,z,x2,NULL);
}
diff --git a/tests/tsum.c b/tests/tsum.c
index 058ae9aff..78664589b 100644
--- a/tests/tsum.c
+++ b/tests/tsum.c
@@ -1,6 +1,6 @@
/* tsum -- test file for the list summation function
-Copyright 2004 Free Software Foundation.
+Copyright 2004, 2005 Free Software Foundation.
This file is part of the MPFR Library.
@@ -100,7 +100,7 @@ main (void)
mpfr_ptr *tabtmp;
unsigned long i, n;
mp_prec_t f;
- mp_rnd_t rnd_mode;
+ int rnd_mode;
mpfr_srcptr *perm;
mpfr_t sum, real_sum, real_non_rounded;
@@ -118,8 +118,8 @@ main (void)
algo_exact (real_non_rounded, tab, n, f);
for (rnd_mode = 0; rnd_mode < GMP_RND_MAX; rnd_mode++)
{
- mpfr_list_sum (sum, tab, n, rnd_mode);
- mpfr_set (real_sum, real_non_rounded, rnd_mode);
+ mpfr_list_sum (sum, tab, n, (mp_rnd_t) rnd_mode);
+ mpfr_set (real_sum, real_non_rounded, (mp_rnd_t) rnd_mode);
if (mpfr_cmp (real_sum, sum) != 0)
{
printf ("mpfr_list_sum incorrect.\n");
@@ -142,8 +142,8 @@ main (void)
for (rnd_mode = 0; rnd_mode < GMP_RND_MAX; rnd_mode++)
{
- mpfr_list_sum (sum, tab, n, rnd_mode);
- mpfr_set (real_sum, real_non_rounded, rnd_mode);
+ mpfr_list_sum (sum, tab, n, (mp_rnd_t) rnd_mode);
+ mpfr_set (real_sum, real_non_rounded, (mp_rnd_t) rnd_mode);
if (mpfr_cmp (real_sum, sum) != 0)
{
printf ("mpfr_list_sum incorrect.\n");
diff --git a/tests/ttanh.c b/tests/ttanh.c
index c99c8331c..f66aa170c 100644
--- a/tests/ttanh.c
+++ b/tests/ttanh.c
@@ -60,8 +60,8 @@ special_overflow (void)
{
mpfr_t x, y;
- mpfr_set_emin (-125);
- mpfr_set_emax (128);
+ set_emin (-125);
+ set_emax (128);
mpfr_init2 (x, 24);
mpfr_init2 (y, 24);
mpfr_set_str_binary (x, "0.101100100000000000110100E7");
@@ -74,8 +74,8 @@ special_overflow (void)
}
mpfr_clear (y);
mpfr_clear (x);
- mpfr_set_emin (MPFR_EMIN_MIN);
- mpfr_set_emax (MPFR_EMAX_MAX);
+ set_emin (MPFR_EMIN_MIN);
+ set_emax (MPFR_EMAX_MAX);
}
int
diff --git a/tests/tui_div.c b/tests/tui_div.c
index ed2777442..ff5d67c86 100644
--- a/tests/tui_div.c
+++ b/tests/tui_div.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_ui_div.
-Copyright 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+Copyright 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -51,7 +51,7 @@ check_inexact (void)
mp_prec_t px, py;
int inexact, cmp;
unsigned long int u;
- mp_rnd_t rnd;
+ int rnd;
mpfr_init (x);
mpfr_init (y);
@@ -72,8 +72,8 @@ check_inexact (void)
mpfr_set_prec (z, py + px);
for (rnd = 0; rnd < GMP_RND_MAX; rnd++)
{
- inexact = mpfr_ui_div (y, u, x, rnd);
- if (mpfr_mul (z, y, x, rnd))
+ inexact = mpfr_ui_div (y, u, x, (mp_rnd_t) rnd);
+ if (mpfr_mul (z, y, x, (mp_rnd_t) rnd))
{
printf ("z <- y * x should be exact\n");
exit (1);
@@ -84,7 +84,7 @@ check_inexact (void)
((inexact < 0) && (cmp >= 0)))
{
printf ("Wrong inexact flag for u=%lu, rnd=%s\n",
- u, mpfr_print_rnd_mode (rnd));
+ u, mpfr_print_rnd_mode ((mp_rnd_t) rnd));
printf ("expected %d, got %d\n", cmp, inexact);
printf ("x="); mpfr_print_binary (x); puts ("");
printf ("y="); mpfr_print_binary (y); puts ("");
diff --git a/tests/tui_pow.c b/tests/tui_pow.c
index 99aebef56..4546e676c 100644
--- a/tests/tui_pow.c
+++ b/tests/tui_pow.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_ui_pow and mpfr_ui_pow_ui.
-Copyright 2001, 2002, 2003, 2004 Free Software Foundation.
+Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation.
Adapted from tarctan.c.
This file is part of the MPFR Library.
@@ -221,7 +221,7 @@ main (int argc, char *argv[])
int nt;
nt = randlimb () & INT_MAX;
mpfr_random (x);
- rnd = RND_RAND ();
+ rnd = (mp_rnd_t) RND_RAND ();
check1 (x, prec, nt, rnd);
}
}
diff --git a/tests/tui_sub.c b/tests/tui_sub.c
index f5978c7b8..3df03ce04 100644
--- a/tests/tui_sub.c
+++ b/tests/tui_sub.c
@@ -1,6 +1,6 @@
/* Test file for mpfr_ui_sub.
-Copyright 2000, 2001, 2002, 2003, 2004 Free Software Foundation.
+Copyright 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation.
This file is part of the MPFR Library.
@@ -129,6 +129,12 @@ special (void)
else
MPFR_ASSERTN(mpfr_cmpabs (x, y) == 0 && mpfr_sgn (x) != mpfr_sgn (y));
+ mpfr_set_prec (x, 73);
+ mpfr_set_str_binary (x, "0.1101111010101011011011100011010000000101110001011111001011011000101111101E-99");
+ mpfr_ui_sub (x, 1, x, GMP_RNDZ);
+ mpfr_nextabove (x);
+ MPFR_ASSERTN(mpfr_cmp_ui (x, 1) == 0);
+
mpfr_clear (x);
mpfr_clear (y);
mpfr_clear (res);
diff --git a/tests/tzeta.c b/tests/tzeta.c
index 1519b26c0..efc4b999f 100644
--- a/tests/tzeta.c
+++ b/tests/tzeta.c
@@ -1,6 +1,6 @@
/* tzeta -- test file for the Riemann Zeta function
-Copyright 2003, 2004 Free Software Foundation.
+Copyright 2003, 2004, 2005 Free Software Foundation.
Contributed by Jean-Luc Re'my and the Spaces project, INRIA Lorraine.
This file is part of the MPFR Library.
@@ -215,7 +215,7 @@ main (int argc, char *argv[])
mpfr_init2 (s, prec);
mpfr_init2 (z, prec);
mpfr_set_str (s, argv[1], 10, GMP_RNDN);
- rnd_mode = atoi(argv[3]);
+ rnd_mode = (mp_rnd_t) atoi(argv[3]);
mpfr_zeta (z, s, rnd_mode);
mpfr_out_str (stdout, 10, 0, z, GMP_RNDN);
diff --git a/ui_sub.c b/ui_sub.c
index f83ef2d0d..1ec0f7ec8 100644
--- a/ui_sub.c
+++ b/ui_sub.c
@@ -1,6 +1,6 @@
/* mpfr_ui_sub -- subtract a floating-point number from an integer
-Copyright 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+Copyright 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of the MPFR Library.
@@ -28,7 +28,10 @@ mpfr_ui_sub (mpfr_ptr y, unsigned long int u, mpfr_srcptr x, mp_rnd_t rnd_mode)
mpfr_t uu;
mp_limb_t up[1];
unsigned long cnt;
-
+
+ if (MPFR_UNLIKELY (u == 0))
+ return mpfr_neg (y, x, rnd_mode);
+
if (MPFR_UNLIKELY(MPFR_IS_SINGULAR(x)))
{
if (MPFR_IS_NAN(x))
@@ -47,7 +50,7 @@ mpfr_ui_sub (mpfr_ptr y, unsigned long int u, mpfr_srcptr x, mp_rnd_t rnd_mode)
/* u - 0 = u */
return mpfr_set_ui(y, u, rnd_mode);
}
- else if (MPFR_LIKELY(u))
+ else
{
MPFR_TMP_INIT1 (up, uu, BITS_PER_MP_LIMB);
MPFR_ASSERTN(u == (mp_limb_t) u);
@@ -56,7 +59,4 @@ mpfr_ui_sub (mpfr_ptr y, unsigned long int u, mpfr_srcptr x, mp_rnd_t rnd_mode)
MPFR_SET_EXP (uu, BITS_PER_MP_LIMB - cnt);
return mpfr_sub (y, uu, x, rnd_mode);
}
- else
- /* u == 0 BUT x != 0 */
- return mpfr_neg (y, x, rnd_mode); /* if u=0, then set y to -x */
}
diff --git a/version.c b/version.c
index 304ae5883..850558bcc 100644
--- a/version.c
+++ b/version.c
@@ -25,5 +25,5 @@ MA 02111-1307, USA. */
const char *
mpfr_get_version (void)
{
- return "2.1.0";
+ return "2.1.1";
}