sqrt.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #include "e.h"
  10. void sqrt(int p2)
  11. {
  12. static int af = 0;
  13. int nps; /* point size for radical */
  14. double radscale = 0.95;
  15. if (ttype == DEVPOST)
  16. radscale = 1.05;
  17. nps = ps * radscale * eht[p2] / EM(1.0,ps) + 0.99; /* kludgy */
  18. nps = max(EFFPS(nps), ps);
  19. yyval = p2;
  20. if (ttype == DEVCAT || ttype == DEVAPS)
  21. eht[yyval] = EM(1.2, nps);
  22. else if (ttype == DEVPOST)
  23. eht[yyval] = EM(1.15, nps);
  24. else /* DEV202, DEVPOST */
  25. eht[yyval] = EM(1.15, nps);
  26. dprintf(".\tS%d <- sqrt S%d;b=%g, h=%g, nps=%d\n",
  27. yyval, p2, ebase[yyval], eht[yyval], nps);
  28. printf(".as %d \\|\n", yyval);
  29. nrwid(p2, ps, p2);
  30. if (af++ == 0)
  31. printf(".af 10 01\n"); /* make it two digits when it prints */
  32. printf(".nr 10 %.3fu*\\n(.su/10\n", 9.2*eht[p2]); /* this nonsense */
  33. /* guesses point size corresponding to height of stuff */
  34. printf(".ds %d \\v'%gm'\\s(\\n(10", yyval, REL(ebase[p2],ps));
  35. if (ttype == DEVCAT || ttype == DEVAPS)
  36. printf("\\v'-.2m'\\(sr\\l'\\n(%du\\(rn'\\v'.2m'", p2);
  37. else /* DEV202, DEVPOST so far */
  38. printf("\\(sr\\l'\\n(%du\\(rn'", p2);
  39. printf("\\s0\\v'%gm'\\h'-\\n(%du'\\^\\*(%d\n", REL(-ebase[p2],ps), p2, p2);
  40. lfont[yyval] = rfont[yyval] = ROM;
  41. }