/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
/* Portions Copyright(c) 1988, Sun Microsystems Inc. */
/* All Rights Reserved */
/*
* Copyright (c) 1997, by Sun Microsystems, Inc.
* All rights reserved.
*/
#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */
/* LINTLIBRARY */
#include <mp.h>
#include "libmp.h"
int
{
int j;
if (a->len < 0)
_mp_fatal("mp_msqrt: neg arg");
if (a->len == 0) {
b->len = 0;
r->len = 0;
return (0);
}
else
;
else
_mp_xfree(b);
_mp_xfree(r);
loop:
mp_madd(&x, &y, &y);
mp_sdiv(&y, 2, &y, (short *) &j);
if (mp_mcmp(&x, &y) > 0) {
_mp_xfree(&x);
_mp_move(&y, &x);
_mp_xfree(&y);
goto loop;
}
_mp_xfree(&y);
_mp_move(&x, b);
mp_mult(&x, &x, &x);
_mp_xfree(&x);
return (r->len);
}