[Gmp-commit] /var/hg/gmp: 3 new changesets

mercurial at gmplib.org mercurial at gmplib.org
Sun Jun 1 19:26:46 UTC 2014


details:   /var/hg/gmp/rev/6b5087d2539c
changeset: 16408:6b5087d2539c
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun Jun 01 21:22:07 2014 +0200
description:
tests/mpf/t-sub.c: correctly handle single limb -> ui convertion.

details:   /var/hg/gmp/rev/dd16653e9605
changeset: 16409:dd16653e9605
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun Jun 01 21:24:33 2014 +0200
description:
tests/mpf/t-int_p.c: Test numbers with both integer and fractionary parts

details:   /var/hg/gmp/rev/afb6dc82ad81
changeset: 16410:afb6dc82ad81
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun Jun 01 21:26:32 2014 +0200
description:
ChangeLog

diffstat:

 ChangeLog           |   4 +++
 tests/mpf/t-int_p.c |   9 ++++++-
 tests/mpf/t-sub.c   |  66 +++++++++++++++++++++++++---------------------------
 3 files changed, 44 insertions(+), 35 deletions(-)

diffs (141 lines):

diff -r 05a5870b130a -r afb6dc82ad81 ChangeLog
--- a/ChangeLog	Sat May 31 21:30:48 2014 +0200
+++ b/ChangeLog	Sun Jun 01 21:26:32 2014 +0200
@@ -4,6 +4,10 @@
 	* tests/mpf/t-sub.c: More corner cases and strict checking.
 	* mpf/sub.c: Use more mpn_ primitives.
 
+	* tests/mpf/t-int_p.c: Test numbers with both integer and
+	fractionary parts.
+
+
 2014-05-29  Marc Glisse  <marc.glisse at inria.fr>
 
 	* gmp-h.in: Include <limits.h>.
diff -r 05a5870b130a -r afb6dc82ad81 tests/mpf/t-int_p.c
--- a/tests/mpf/t-int_p.c	Sat May 31 21:30:48 2014 +0200
+++ b/tests/mpf/t-int_p.c	Sun Jun 01 21:26:32 2014 +0200
@@ -1,6 +1,6 @@
 /* Test mpf_integer_p.
 
-Copyright 2001 Free Software Foundation, Inc.
+Copyright 2001, 2014 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library test suite.
 
@@ -74,10 +74,17 @@
   mpf_set_str (f, "0.5", 10);
   all (f, 0);
 
+  mpf_set_str (f, "2.5", 10);
+  all (f, 0);
+
   mpf_set_ui (f, 1L);
   mpf_div_ui (f, f, 3L);
   all (f, 0);
 
+  mpf_set_ui (f, 7L);
+  mpf_div_ui (f, f, 3L);
+  all (f, 0);
+
   mpf_clear (f);
   tests_end ();
   exit (0);
diff -r 05a5870b130a -r afb6dc82ad81 tests/mpf/t-sub.c
--- a/tests/mpf/t-sub.c	Sat May 31 21:30:48 2014 +0200
+++ b/tests/mpf/t-sub.c	Sun Jun 01 21:26:32 2014 +0200
@@ -1,6 +1,6 @@
 /* Test mpf_sub.
 
-Copyright 1996, 2001, 2004 Free Software Foundation, Inc.
+Copyright 1996, 2001, 2004, 2014 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library test suite.
 
@@ -79,7 +79,7 @@
       refmpf_sub (wref, u, v);
 
       mpf_reldiff (rerr, w, wref);
-      if (! refmpf_validate ("mpf_ui_sub", w, wref))
+      if (! refmpf_validate ("check_rand mpf_sub", w, wref))
 	{
 	  mpf_set (max_rerr, rerr);
 #if VERBOSE
@@ -224,47 +224,45 @@
 
 	  if (SIZ (x) == 1 || SIZ (x) == 0 )
 	    {
-	      if (SIZ (x))
+	      if (SIZ (y)) EXP (y) -= EXP (x) - (mp_exp_t) SIZ (x);
+	      if (SIZ (want)) EXP (want) -= EXP (x) - (mp_exp_t) SIZ (x);
+	      EXP (x) = (mp_exp_t) SIZ (x);
+
+	      if (mpf_fits_uint_p (x))
 		{
-		  if (SIZ (y)) EXP (y) -= EXP (x) - 1;
-		  if (SIZ (want)) EXP (want) -= EXP (x) - 1;
-		  EXP (x) = 1;
-		  mpf_ui_sub (got, * PTR (x), y);
-		}
-	      else
-		mpf_ui_sub (got, 0, y);
+		  mpf_ui_sub (got, mpf_get_ui (x), y);
 	    
-	      if (! refmpf_validate ("mpf_ui_sub", got, want))
-		{
-		  printf ("check_data() wrong result at data[%d] (operands%s swapped)\n", i, swap ? "" : " not");
-		  mpf_trace ("x   ", x);
-		  mpf_trace ("y   ", y);
-		  mpf_trace ("got ", got);
-		  mpf_trace ("want", want);
-		  fail = 1;
+		  if (! refmpf_validate ("mpf_ui_sub", got, want))
+		    {
+		      printf ("check_data() wrong result at data[%d] (operands%s swapped)\n", i, swap ? "" : " not");
+		      mpf_trace ("x   ", x);
+		      mpf_trace ("y   ", y);
+		      mpf_trace ("got ", got);
+		      mpf_trace ("want", want);
+		      fail = 1;
+		    }
 		}
 	    }
 
 	  if (SIZ (y) == 1 || SIZ (y) == 0)
 	    {
-	      if (SIZ (y))
+	      if (SIZ (x)) EXP (x) -= EXP (y) - (mp_exp_t) SIZ (y);
+	      if (SIZ (want)) EXP (want) -= EXP (y) - (mp_exp_t) SIZ (y);
+	      EXP (y) = (mp_exp_t) SIZ (y);
+
+	      if (mpf_fits_uint_p (x))
 		{
-		  if (SIZ (x)) EXP (x) -= EXP (y) - 1;
-		  if (SIZ (want)) EXP (want) -= EXP (y) - 1;
-		  EXP (y) = 1;
-		  mpf_sub_ui (got, x, * PTR (y));
-		}
-	      else
-		mpf_sub_ui (got, x, 0);
+		  mpf_sub_ui (got, x, mpf_get_ui (y));
 
-	      if (! refmpf_validate ("mpf_ui_sub", got, want))
-		{
-		  printf ("check_data() wrong result at data[%d] (operands%s swapped)\n", i, swap ? "" : " not");
-		  mpf_trace ("x   ", x);
-		  mpf_trace ("y   ", y);
-		  mpf_trace ("got ", got);
-		  mpf_trace ("want", want);
-		  fail = 1;
+		  if (! refmpf_validate ("mpf_sub_ui", got, want))
+		    {
+		      printf ("check_data() wrong result at data[%d] (operands%s swapped)\n", i, swap ? "" : " not");
+		      mpf_trace ("x   ", x);
+		      mpf_trace ("y   ", y);
+		      mpf_trace ("got ", got);
+		      mpf_trace ("want", want);
+		      fail = 1;
+		    }
 		}
 	    }
 


More information about the gmp-commit mailing list