xref: /illumos-gate/usr/src/cmd/eqn/sqrt.c (revision 2a8bcb4e)
1*779fc935Sceastha /*
2*779fc935Sceastha  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
3*779fc935Sceastha  * Use is subject to license terms.
4*779fc935Sceastha  */
5*779fc935Sceastha 
67c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
77c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
87c478bd9Sstevel@tonic-gate 
97c478bd9Sstevel@tonic-gate /*
107c478bd9Sstevel@tonic-gate  * Copyright (c) 1980 Regents of the University of California.
117c478bd9Sstevel@tonic-gate  * All rights reserved. The Berkeley software License Agreement
127c478bd9Sstevel@tonic-gate  * specifies the terms and conditions for redistribution.
137c478bd9Sstevel@tonic-gate  */
147c478bd9Sstevel@tonic-gate 
15*779fc935Sceastha #include "e.h"
167c478bd9Sstevel@tonic-gate 
17*779fc935Sceastha void
sqrt(int p2)18*779fc935Sceastha sqrt(int p2)
19*779fc935Sceastha {
207c478bd9Sstevel@tonic-gate #ifndef NEQN
217c478bd9Sstevel@tonic-gate 	int nps;
227c478bd9Sstevel@tonic-gate 
237c478bd9Sstevel@tonic-gate 	nps = EFFPS(((eht[p2]*9)/10+(resolution/POINT-1))/(resolution/POINT));
24*779fc935Sceastha #endif	/* NEQN */
257c478bd9Sstevel@tonic-gate 	yyval = p2;
267c478bd9Sstevel@tonic-gate #ifndef NEQN
277c478bd9Sstevel@tonic-gate 	eht[yyval] = VERT(EM(1.2, nps));
28*779fc935Sceastha 	if (dbg)
29*779fc935Sceastha 		printf(".\tsqrt: S%d <- S%d;b=%d, h=%d\n",
30*779fc935Sceastha 		    yyval, p2, ebase[yyval], eht[yyval]);
317c478bd9Sstevel@tonic-gate 	if (rfont[yyval] == ITAL)
327c478bd9Sstevel@tonic-gate 		printf(".as %d \\|\n", yyval);
33*779fc935Sceastha #endif	/* NEQN */
347c478bd9Sstevel@tonic-gate 	nrwid(p2, ps, p2);
357c478bd9Sstevel@tonic-gate #ifndef NEQN
36*779fc935Sceastha 	printf(".ds %d \\v'%du'\\s%d\\v'-.2m'\\(sr\\l'\\n(%du\\"
37*779fc935Sceastha 	    "(rn'\\v'.2m'\\s%d", yyval, ebase[p2], nps, p2, ps);
387c478bd9Sstevel@tonic-gate 	printf("\\v'%du'\\h'-\\n(%du'\\*(%d\n", -ebase[p2], p2, p2);
397c478bd9Sstevel@tonic-gate 	lfont[yyval] = ROM;
40*779fc935Sceastha #else	/* NEQN */
417c478bd9Sstevel@tonic-gate 	printf(".ds %d \\v'%du'\\e\\L'%du'\\l'\\n(%du'",
42*779fc935Sceastha 	    p2, ebase[p2], -eht[p2], p2);
437c478bd9Sstevel@tonic-gate 	printf("\\v'%du'\\h'-\\n(%du'\\*(%d\n", eht[p2]-ebase[p2], p2, p2);
447c478bd9Sstevel@tonic-gate 	eht[p2] += VERT(1);
45*779fc935Sceastha 	if (dbg)
46*779fc935Sceastha 		printf(".\tsqrt: S%d <- S%d;b=%d, h=%d\n",
47*779fc935Sceastha 		    p2, p2, ebase[p2], eht[p2]);
48*779fc935Sceastha #endif	/* NEQN */
497c478bd9Sstevel@tonic-gate }
50