summaryrefslogtreecommitdiff
path: root/tests/refmpf.c
diff options
context:
space:
mode:
authorKevin Ryde <user42@zip.com.au>2004-03-13 23:53:07 +0100
committerKevin Ryde <user42@zip.com.au>2004-03-13 23:53:07 +0100
commit8e82250e3525eda20363c50d39c3dda1bc924367 (patch)
treec1c1781953c0e65abc07aba7d5abe5c14b606071 /tests/refmpf.c
parent5fdf90cad7d33cbc79353b6edec6c6338a70535e (diff)
downloadgmp-8e82250e3525eda20363c50d39c3dda1bc924367.tar.gz
* tests/refmpf.c, tests/tests.h (refmpf_set_overlap): New function.
Diffstat (limited to 'tests/refmpf.c')
-rw-r--r--tests/refmpf.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/refmpf.c b/tests/refmpf.c
index 0fe6561f4..42ff1f772 100644
--- a/tests/refmpf.c
+++ b/tests/refmpf.c
@@ -166,6 +166,29 @@ refmpf_normalize (mpf_ptr f)
EXP(f) = 0;
}
+/* refmpf_set_overlap sets up dst as a copy of src, but with PREC(dst)
+ unchanged, in preparation for an overlap test.
+
+ The full value of src is copied, and the space at PTR(dst) is extended as
+ necessary. The way PREC(dst) is unchanged is as per an mpf_set_prec_raw.
+ The return value is the new PTR(dst) space precision, in bits, ready for
+ a restoring mpf_set_prec_raw before mpf_clear. */
+
+unsigned long
+refmpf_set_overlap (mpf_ptr dst, mpf_srcptr src)
+{
+ mp_size_t dprec = PREC(dst);
+ mp_size_t ssize = ABSIZ(src);
+ unsigned long ret;
+
+ refmpf_set_prec_limbs (dst, (unsigned long) MAX (dprec, ssize));
+ mpf_set (dst, src);
+
+ ret = mpf_get_prec (dst);
+ PREC(dst) = dprec;
+ return ret;
+}
+
/* Like mpf_set_prec, but taking a precision in limbs.
PREC(f) ends up as the given "prec" value. */
void