xref: /original-bsd/old/eqn/common_source/sqrt.c (revision 07303858)
1 /*-
2  * Copyright (c) 1991 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.proprietary.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)sqrt.c	4.5 (Berkeley) 03/01/93";
10 #endif /* not lint */
11 
12 # include "e.h"
13 
14 eqsqrt(p2) int p2; {
15 #ifndef NEQN
16 	int nps;
17 
18 	nps = EFFPS(((eht[p2]*9)/10+5)/6);
19 #endif NEQN
20 	yyval = p2;
21 #ifndef NEQN
22 	eht[yyval] = VERT( (nps*6*12)/10 );
23 	if(dbg)printf(".\tsqrt: S%d <- S%d;b=%d, h=%d\n",
24 		yyval, p2, ebase[yyval], eht[yyval]);
25 	if (rfont[yyval] == ITAL)
26 		printf(".as %d \\|\n", yyval);
27 #endif NEQN
28 	nrwid(p2, ps, p2);
29 #ifndef NEQN
30 	printf(".ds %d \\v'%du'\\s%d\\v'-.2m'\\(sr\\l'\\n(%du\\(rn'\\v'.2m'\\s%d",
31 		yyval, ebase[p2], nps, p2, ps);
32 	printf("\\v'%du'\\h'-\\n(%du'\\*(%d\n", -ebase[p2], p2, p2);
33 	lfont[yyval] = ROM;
34 #else NEQN
35 	printf(".ds %d \\v'%du'\\e\\L'%du'\\l'\\n(%du'",
36 		p2, ebase[p2], -eht[p2], p2);
37 	printf("\\v'%du'\\h'-\\n(%du'\\*(%d\n", eht[p2]-ebase[p2], p2, p2);
38 	eht[p2] += VERT(1);
39 	if(dbg)printf(".\tsqrt: S%d <- S%d;b=%d, h=%d\n",
40 		p2, p2, ebase[p2], eht[p2]);
41 #endif NEQN
42 }
43