[Gmp-commit] /var/hg/gmp: Avoid overflows in the exponents in an mpf test.

mercurial at gmplib.org mercurial at gmplib.org
Tue Oct 8 18:55:32 CEST 2013


details:   /var/hg/gmp/rev/3db7f0f74219
changeset: 16035:3db7f0f74219
user:      Marc Glisse <marc.glisse at inria.fr>
date:      Tue Oct 08 18:54:52 2013 +0200
description:
Avoid overflows in the exponents in an mpf test.

diffstat:

 ChangeLog         |  2 ++
 tests/mpf/reuse.c |  6 ++++++
 2 files changed, 8 insertions(+), 0 deletions(-)

diffs (35 lines):

diff -r 6cd3658f5621 -r 3db7f0f74219 ChangeLog
--- a/ChangeLog	Tue Oct 08 14:45:27 2013 +0200
+++ b/ChangeLog	Tue Oct 08 18:54:52 2013 +0200
@@ -5,6 +5,8 @@
 
 	* gmp-h.in: Remove __need_size_t.
 
+	* tests/mpf/reuse.c (main): Use small numbers as exponents.
+
 2013-10-05  Torbjorn Granlund  <tege at gmplib.org>
 
 	* mpn/x86_64/atom/aorsmul_1.asm: Slight tweak.
diff -r 6cd3658f5621 -r 3db7f0f74219 tests/mpf/reuse.c
--- a/tests/mpf/reuse.c	Tue Oct 08 14:45:27 2013 +0200
+++ b/tests/mpf/reuse.c	Tue Oct 08 18:54:52 2013 +0200
@@ -66,6 +66,8 @@
 
 typedef void (*dsi_func) (mpf_ptr, mpf_srcptr, unsigned long int);
 
+/* The order matters. For mpf_mul_2exp and the functions after it,
+   we use a small number in the tests since it represents an exponent.  */
 dsi_func dsi_funcs[] =
 {
   mpf_div_ui, mpf_add_ui, mpf_mul_ui, mpf_sub_ui,
@@ -152,6 +154,10 @@
 	  if (strcmp (dsi_func_names[i], "mpf_div_ui") == 0 && in2i == 0)
 	    continue;
 
+	  /* Avoid overflows in the exponent.  */
+	  if (strcmp (dsi_func_names[i], "mpf_mul_2exp") == 0)
+	    in2i %= 64;
+
 	  (dsi_funcs[i]) (res1, in1, in2i);
 
 	  mpf_set (out1, in1);


More information about the gmp-commit mailing list