xref: /csrg-svn/old/eqn/common_source/sqrt.c (revision 48252)
1*48252Sbostic /*-
2*48252Sbostic  * Copyright (c) 1991 The Regents of the University of California.
3*48252Sbostic  * All rights reserved.
4*48252Sbostic  *
5*48252Sbostic  * %sccs.include.proprietary.c%
6*48252Sbostic  */
7*48252Sbostic 
814486Ssam #ifndef lint
9*48252Sbostic static char sccsid[] = "@(#)sqrt.c	4.4 (Berkeley) 04/17/91";
10*48252Sbostic #endif /* not lint */
1111018Sshannon 
1211018Sshannon # include "e.h"
1311018Sshannon 
1411018Sshannon sqrt(p2) int p2; {
1511023Sshannon #ifndef NEQN
1611018Sshannon 	int nps;
1711023Sshannon 
1811018Sshannon 	nps = EFFPS(((eht[p2]*9)/10+5)/6);
1911023Sshannon #endif NEQN
2011018Sshannon 	yyval = p2;
2111023Sshannon #ifndef NEQN
2211018Sshannon 	eht[yyval] = VERT( (nps*6*12)/10 );
2311018Sshannon 	if(dbg)printf(".\tsqrt: S%d <- S%d;b=%d, h=%d\n",
2411018Sshannon 		yyval, p2, ebase[yyval], eht[yyval]);
2511018Sshannon 	if (rfont[yyval] == ITAL)
2611018Sshannon 		printf(".as %d \\|\n", yyval);
2711023Sshannon #endif NEQN
2811018Sshannon 	nrwid(p2, ps, p2);
2911023Sshannon #ifndef NEQN
3011018Sshannon 	printf(".ds %d \\v'%du'\\s%d\\v'-.2m'\\(sr\\l'\\n(%du\\(rn'\\v'.2m'\\s%d",
3111018Sshannon 		yyval, ebase[p2], nps, p2, ps);
3211018Sshannon 	printf("\\v'%du'\\h'-\\n(%du'\\*(%d\n", -ebase[p2], p2, p2);
3311018Sshannon 	lfont[yyval] = ROM;
3411023Sshannon #else NEQN
3511023Sshannon 	printf(".ds %d \\v'%du'\\e\\L'%du'\\l'\\n(%du'",
3611023Sshannon 		p2, ebase[p2], -eht[p2], p2);
3711023Sshannon 	printf("\\v'%du'\\h'-\\n(%du'\\*(%d\n", eht[p2]-ebase[p2], p2, p2);
3811023Sshannon 	eht[p2] += VERT(1);
3911023Sshannon 	if(dbg)printf(".\tsqrt: S%d <- S%d;b=%d, h=%d\n",
4011023Sshannon 		p2, p2, ebase[p2], eht[p2]);
4111023Sshannon #endif NEQN
4211018Sshannon }
43