xref: /csrg-svn/old/eqn/common_source/sqrt.c (revision 14486)
1*14486Ssam #ifndef lint
2*14486Ssam static char sccsid[] = "@(#)sqrt.c	4.3 08/11/83";
3*14486Ssam #endif
411018Sshannon 
511018Sshannon # include "e.h"
611018Sshannon 
711018Sshannon sqrt(p2) int p2; {
811023Sshannon #ifndef NEQN
911018Sshannon 	int nps;
1011023Sshannon 
1111018Sshannon 	nps = EFFPS(((eht[p2]*9)/10+5)/6);
1211023Sshannon #endif NEQN
1311018Sshannon 	yyval = p2;
1411023Sshannon #ifndef NEQN
1511018Sshannon 	eht[yyval] = VERT( (nps*6*12)/10 );
1611018Sshannon 	if(dbg)printf(".\tsqrt: S%d <- S%d;b=%d, h=%d\n",
1711018Sshannon 		yyval, p2, ebase[yyval], eht[yyval]);
1811018Sshannon 	if (rfont[yyval] == ITAL)
1911018Sshannon 		printf(".as %d \\|\n", yyval);
2011023Sshannon #endif NEQN
2111018Sshannon 	nrwid(p2, ps, p2);
2211023Sshannon #ifndef NEQN
2311018Sshannon 	printf(".ds %d \\v'%du'\\s%d\\v'-.2m'\\(sr\\l'\\n(%du\\(rn'\\v'.2m'\\s%d",
2411018Sshannon 		yyval, ebase[p2], nps, p2, ps);
2511018Sshannon 	printf("\\v'%du'\\h'-\\n(%du'\\*(%d\n", -ebase[p2], p2, p2);
2611018Sshannon 	lfont[yyval] = ROM;
2711023Sshannon #else NEQN
2811023Sshannon 	printf(".ds %d \\v'%du'\\e\\L'%du'\\l'\\n(%du'",
2911023Sshannon 		p2, ebase[p2], -eht[p2], p2);
3011023Sshannon 	printf("\\v'%du'\\h'-\\n(%du'\\*(%d\n", eht[p2]-ebase[p2], p2, p2);
3111023Sshannon 	eht[p2] += VERT(1);
3211023Sshannon 	if(dbg)printf(".\tsqrt: S%d <- S%d;b=%d, h=%d\n",
3311023Sshannon 		p2, p2, ebase[p2], eht[p2]);
3411023Sshannon #endif NEQN
3511018Sshannon }
36