xref: /onnv-gate/usr/src/cmd/eqn/sqrt.c (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
2*0Sstevel@tonic-gate /*	  All Rights Reserved  	*/
3*0Sstevel@tonic-gate 
4*0Sstevel@tonic-gate 
5*0Sstevel@tonic-gate /*
6*0Sstevel@tonic-gate  * Copyright (c) 1980 Regents of the University of California.
7*0Sstevel@tonic-gate  * All rights reserved. The Berkeley software License Agreement
8*0Sstevel@tonic-gate  * specifies the terms and conditions for redistribution.
9*0Sstevel@tonic-gate  */
10*0Sstevel@tonic-gate 
11*0Sstevel@tonic-gate /*
12*0Sstevel@tonic-gate  * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc.
13*0Sstevel@tonic-gate  * All Rights Reserved.
14*0Sstevel@tonic-gate  */
15*0Sstevel@tonic-gate 
16*0Sstevel@tonic-gate #ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.1	*/
17*0Sstevel@tonic-gate 
18*0Sstevel@tonic-gate # include "e.h"
19*0Sstevel@tonic-gate 
20*0Sstevel@tonic-gate sqrt(p2) int p2; {
21*0Sstevel@tonic-gate #ifndef NEQN
22*0Sstevel@tonic-gate 	int nps;
23*0Sstevel@tonic-gate 
24*0Sstevel@tonic-gate 	nps = EFFPS(((eht[p2]*9)/10+(resolution/POINT-1))/(resolution/POINT));
25*0Sstevel@tonic-gate #endif NEQN
26*0Sstevel@tonic-gate 	yyval = p2;
27*0Sstevel@tonic-gate #ifndef NEQN
28*0Sstevel@tonic-gate 	eht[yyval] = VERT(EM(1.2, nps));
29*0Sstevel@tonic-gate 	if(dbg)printf(".\tsqrt: S%d <- S%d;b=%d, h=%d\n",
30*0Sstevel@tonic-gate 		yyval, p2, ebase[yyval], eht[yyval]);
31*0Sstevel@tonic-gate 	if (rfont[yyval] == ITAL)
32*0Sstevel@tonic-gate 		printf(".as %d \\|\n", yyval);
33*0Sstevel@tonic-gate #endif NEQN
34*0Sstevel@tonic-gate 	nrwid(p2, ps, p2);
35*0Sstevel@tonic-gate #ifndef NEQN
36*0Sstevel@tonic-gate 	printf(".ds %d \\v'%du'\\s%d\\v'-.2m'\\(sr\\l'\\n(%du\\(rn'\\v'.2m'\\s%d",
37*0Sstevel@tonic-gate 		yyval, ebase[p2], nps, p2, ps);
38*0Sstevel@tonic-gate 	printf("\\v'%du'\\h'-\\n(%du'\\*(%d\n", -ebase[p2], p2, p2);
39*0Sstevel@tonic-gate 	lfont[yyval] = ROM;
40*0Sstevel@tonic-gate #else NEQN
41*0Sstevel@tonic-gate 	printf(".ds %d \\v'%du'\\e\\L'%du'\\l'\\n(%du'",
42*0Sstevel@tonic-gate 		p2, ebase[p2], -eht[p2], p2);
43*0Sstevel@tonic-gate 	printf("\\v'%du'\\h'-\\n(%du'\\*(%d\n", eht[p2]-ebase[p2], p2, p2);
44*0Sstevel@tonic-gate 	eht[p2] += VERT(1);
45*0Sstevel@tonic-gate 	if(dbg)printf(".\tsqrt: S%d <- S%d;b=%d, h=%d\n",
46*0Sstevel@tonic-gate 		p2, p2, ebase[p2], eht[p2]);
47*0Sstevel@tonic-gate #endif NEQN
48*0Sstevel@tonic-gate }
49