1 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
2 /* All Rights Reserved */
3
4
5 /*
6 * Copyright (c) 1980 Regents of the University of California.
7 * All rights reserved. The Berkeley software License Agreement
8 * specifies the terms and conditions for redistribution.
9 */
10
11 /*
12 * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc.
13 * All Rights Reserved.
14 */
15
16 /* from OpenSolaris "sqrt.c 1.4 05/06/02 SMI" SVr4.0 1.1 */
17
18 /*
19 * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany
20 *
21 * Sccsid @(#)sqrt.c 1.6 (gritter) 1/13/08
22 */
23
24 /*
25 * Changes Copyright (c) 2014 Carsten Kunze (carsten.kunze at arcor.de)
26 */
27
28 # include "e.h"
29 #include "y.tab.h"
30
31 extern YYSTYPE yyval;
32
33 void
sqrt(int p2)34 sqrt(int p2) {
35 #ifndef NEQN
36 float nps;
37
38 nps = (int)(EFFPS(((eht[p2]*9)/10+(resolution/POINT-1))/(resolution/POINT)));
39 #endif /* NEQN */
40 yyval.token = p2;
41 #ifndef NEQN
42 eht[yyval.token] = VERT(EM(1.2, nps));
43 if(dbg)printf(".\tsqrt: S%d <- S%d;b=%g, h=%g\n",
44 yyval.token, p2, ebase[yyval.token], eht[yyval.token]);
45 if (ital(rfont[yyval.token]))
46 printf(".as %d \\|\n", yyval.token);
47 #endif /* NEQN */
48 nrwid(p2, ps, p2);
49 #ifndef NEQN
50 printf(".ds %d \\v'%gp'\\s%s\\v'-.2m'\\(sr\\l'\\n(%du\\(rn'\\v'.2m'\\s%s",
51 yyval.token, ebase[p2], tsize(nps), p2, tsize(ps));
52 printf("\\v'%gp'\\h'-\\n(%du'\\*(%d\n", -ebase[p2], p2, p2);
53 lfont[yyval.token] = ROM;
54 #else /* NEQN */
55 printf(".ds %d \\v'%du'\\e\\L'%du'\\l'\\n(%du'",
56 p2, ebase[p2], -eht[p2], p2);
57 printf("\\v'%du'\\h'-\\n(%du'\\*(%d\n", eht[p2]-ebase[p2], p2, p2);
58 eht[p2] += VERT(1);
59 if(dbg)printf(".\tsqrt: S%d <- S%d;b=%d, h=%d\n",
60 p2, p2, ebase[p2], eht[p2]);
61 #endif /* NEQN */
62 }
63