X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/65397be71373e71fd364cc3bb436dfe34e4c6a31..92c494cebdce7068e6c9c0fe4363467719c8ed67:/mp-sqrt.c diff --git a/mp-sqrt.c b/mp-sqrt.c index 98741e8..01fe000 100644 --- a/mp-sqrt.c +++ b/mp-sqrt.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: mp-sqrt.c,v 1.1 2000/06/22 19:01:44 mdw Exp $ + * $Id: mp-sqrt.c,v 1.5 2004/04/08 01:36:15 mdw Exp $ * * Compute integer square roots * @@ -27,14 +27,6 @@ * MA 02111-1307, USA. */ -/*----- Revision history --------------------------------------------------* - * - * $Log: mp-sqrt.c,v $ - * Revision 1.1 2000/06/22 19:01:44 mdw - * Compute (approximations to) integer square roots. - * - */ - /*----- Header files ------------------------------------------------------*/ #include "mp.h" @@ -68,8 +60,7 @@ mp *mp_sqrt(mp *d, mp *a) MP_SHRINK(a); if (a->v == a->vl) { - if (d) - mp_drop(d); + mp_drop(d); return (MP_ZERO); } @@ -79,7 +70,6 @@ mp *mp_sqrt(mp *d, mp *a) z >>= 1; mp_copy(a); d = mp_lsr(d, a, z); - mp_drop(a); /* --- Main approximation --- * * @@ -112,9 +102,9 @@ mp *mp_sqrt(mp *d, mp *a) /* --- Finished, at last --- */ + mp_drop(a); mp_drop(q); - if (r) - mp_drop(r); + mp_drop(r); return (d); } @@ -131,7 +121,7 @@ static int verify(dstr *v) mp *q = mp_sqrt(MP_NEW, a); int ok = 1; - if (MP_CMP(q, !=, qq)) { + if (!MP_EQ(q, qq)) { ok = 0; fputs("\n*** sqrt failed", stderr); fputs("\n*** a = ", stderr); mp_writefile(a, stderr, 10);