1 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
2 /* All Rights Reserved */
6 * Copyright (c) 1980 Regents of the University of California.
7 * All rights reserved. The Berkeley software License Agreement
8 * specifies the terms and conditions for redistribution.
10 /* Portions Copyright(c) 1988, Sun Microsystems Inc. */
11 /* All Rights Reserved */
14 * Copyright (c) 1997, by Sun Microsystems, Inc.
15 * All rights reserved.
18 #ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */
23 #include <sys/types.h>
27 mp_msqrt(MINT
*a
, MINT
*b
, MINT
*r
)
32 a0
.len
= junk
.len
= y
.len
= 0;
34 _mp_fatal("mp_msqrt: neg arg");
41 x
.len
= (1 + a
->len
) / 2;
43 x
.len
= 1 + a
->len
/ 2;
44 x
.val
= _mp_xalloc(x
.len
, "mp_msqrt");
45 for (j
= 0; j
< x
.len
; x
.val
[j
++] = 0)
48 x
.val
[x
.len
- 1] = 0400;
55 mp_mdiv(&a0
, &x
, &y
, &junk
);
58 mp_sdiv(&y
, 2, &y
, (short *) &j
);
59 if (mp_mcmp(&x
, &y
) > 0) {