xref: /onnv-gate/usr/src/cmd/eqn/sqrt.c (revision 364:f36290b8cb0b)
1*364Sceastha /*
2*364Sceastha  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
3*364Sceastha  * Use is subject to license terms.
4*364Sceastha  */
5*364Sceastha 
60Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
70Sstevel@tonic-gate /*	  All Rights Reserved  	*/
80Sstevel@tonic-gate 
90Sstevel@tonic-gate /*
100Sstevel@tonic-gate  * Copyright (c) 1980 Regents of the University of California.
110Sstevel@tonic-gate  * All rights reserved. The Berkeley software License Agreement
120Sstevel@tonic-gate  * specifies the terms and conditions for redistribution.
130Sstevel@tonic-gate  */
14*364Sceastha 
15*364Sceastha #pragma ident	"%Z%%M%	%I%	%E% SMI"
160Sstevel@tonic-gate 
17*364Sceastha #include "e.h"
180Sstevel@tonic-gate 
19*364Sceastha void
sqrt(int p2)20*364Sceastha sqrt(int p2)
21*364Sceastha {
220Sstevel@tonic-gate #ifndef NEQN
230Sstevel@tonic-gate 	int nps;
240Sstevel@tonic-gate 
250Sstevel@tonic-gate 	nps = EFFPS(((eht[p2]*9)/10+(resolution/POINT-1))/(resolution/POINT));
26*364Sceastha #endif	/* NEQN */
270Sstevel@tonic-gate 	yyval = p2;
280Sstevel@tonic-gate #ifndef NEQN
290Sstevel@tonic-gate 	eht[yyval] = VERT(EM(1.2, nps));
30*364Sceastha 	if (dbg)
31*364Sceastha 		printf(".\tsqrt: S%d <- S%d;b=%d, h=%d\n",
32*364Sceastha 		    yyval, p2, ebase[yyval], eht[yyval]);
330Sstevel@tonic-gate 	if (rfont[yyval] == ITAL)
340Sstevel@tonic-gate 		printf(".as %d \\|\n", yyval);
35*364Sceastha #endif	/* NEQN */
360Sstevel@tonic-gate 	nrwid(p2, ps, p2);
370Sstevel@tonic-gate #ifndef NEQN
38*364Sceastha 	printf(".ds %d \\v'%du'\\s%d\\v'-.2m'\\(sr\\l'\\n(%du\\"
39*364Sceastha 	    "(rn'\\v'.2m'\\s%d", yyval, ebase[p2], nps, p2, ps);
400Sstevel@tonic-gate 	printf("\\v'%du'\\h'-\\n(%du'\\*(%d\n", -ebase[p2], p2, p2);
410Sstevel@tonic-gate 	lfont[yyval] = ROM;
42*364Sceastha #else	/* NEQN */
430Sstevel@tonic-gate 	printf(".ds %d \\v'%du'\\e\\L'%du'\\l'\\n(%du'",
44*364Sceastha 	    p2, ebase[p2], -eht[p2], p2);
450Sstevel@tonic-gate 	printf("\\v'%du'\\h'-\\n(%du'\\*(%d\n", eht[p2]-ebase[p2], p2, p2);
460Sstevel@tonic-gate 	eht[p2] += VERT(1);
47*364Sceastha 	if (dbg)
48*364Sceastha 		printf(".\tsqrt: S%d <- S%d;b=%d, h=%d\n",
49*364Sceastha 		    p2, p2, ebase[p2], eht[p2]);
50*364Sceastha #endif	/* NEQN */
510Sstevel@tonic-gate }
52