1 /*
2 * MIRACL RATIONAL CALCULATOR - IBM-PC VERSION
3 * Compiles with Turbo C V1.0+, Microsoft C V3.0+ or Zortech C++ V2.0
4 * ** Change display mode for 40/80 column operation (e.g. 'mode 40' to DOS)
5 * ** Change colour/B&W below
6 */
7
8 #include <stdio.h> /*** IBM-PC specific section ***/
9 #include <string.h>
10 #include <dos.h>
11 #include "miracl.h"
12
13 #define ESC 27
14 #define SPACE 32
15 #define BELL 7
16
17 #define DVERT 186
18 #define DHORZ 205
19 #define DTLHC 201
20 #define DTRHC 187
21 #define DBLHC 200
22 #define DBRHC 188
23 #define VERT 179
24 #define HORZ 196
25 #define TLHC 218
26 #define TRHC 191
27 #define BLHC 192
28 #define BRHC 217
29 #define LSIDE 199
30 #define RSIDE 182
31
32 /* Globals */
33 /* set colours B/W Colours (suggested) */
34
35 static int ORDINARY=0x17; /* 0x07 0x17 blue-white */
36 static int INVER =0x40; /* 0x70 0x40 red-black */
37 static int BOLD =0x70; /* 0x0F 0x70 white-black */
38 static int BLINKING=0xF4; /* 0x87 0xF4 white-red (blink) */
39 static int HELPCOL =0x02; /* 0x07 0x02 black-green */
40 static int PRESSED =0x4F; /* 0x0F 0x4F red-white (bold) */
41 static int STATCOL =0x74; /* 0x07 0x74 white-red */
42 static int BGROUND =0x07; /* 0x07 0x07 black-white */
43
44 static int dmode;
45
46 #if MIRACL==16
47 /*** Constants 16-bit values ***/
48
49 static char cpi[] = "636254619847503442989626/202526135627569822173415";
50 static char clg2[]= "505741081295988878347013/729630149959545241557174";
51 static char clg10[]="979037493951642967431763/425190581199586827388880";
52
53 #else
54 /*** Constants 32-bit values ***/
55
56 static char cpi[] = "67165660610256098973103849091/21379493784309731162770152371";
57 static char clg2[]= "16574595208316928044019202463/23912086311780807469140302041";
58 static char clg10[]="2379577069267877188193568690/1033437190446551110271192309";
59
60 #endif
61
62 static char ceps[]="1/100000000000000000000000000000000000";
63
64 /*** Device independent data ***/
65
66 static char *settings[4][4]=
67 {" ","HYP","","",
68 "Be ","B2 ","B10","",
69 "RAD","DEG","GRA","",
70 "DEC","HEX","OCT","BIN"};
71
72 static int nops[]= {1,2,1,3}; /* number of options */
73 static int opp[] = {0,1,1,2,2,3,3,2}; /* operator precedence */
74
75 static char *keys[6][7]=
76 {"SIN","COS","TAN","EXP","F-D","CLR","OFF",
77 "ASN","ACS","ATN","LOG","SET","MOD","DEL",
78 " 7 "," 8 "," 9 ","Y^X","X�Y"," � "," RM", /******/
79 " 4 "," 5 "," 6 "," X�","��X"," x "," M+",
80 " 1 "," 2 "," 3 ","1/X"," � "," - ","+/-",
81 " 0 "," / "," . "," ( "," ) "," + "," = "};
82
83 static int qkeys[6][7]=
84 {'s','k','t','e','f','c','o',
85 'S','K','T','l','g','%','<',
86 '7','8','9','y','x','\\','r',
87 '4','5','6','q','v','*','m',
88 '1','2','3','i','p','-',';',
89 '0','/','.','(',')','+','='};
90
91 static char *htext[]=
92 {"Arrow keys find, space bar activates OR",
93 "use numeric keys (with A-F for hex),",
94 "brackets, and mnemonic keys as below: ",
95 " FUNCTION KEY FUNCTION KEY",
96 " SIN s ASN S ",
97 " COS k ACS K ",
98 " TAN t ATN T ",
99 " EXP(e/2/10) e LOG(e/2/10) l ",
100 " Y^X ^ or y X�Y x ", /******/
101 " X� q ��X v ",
102 " 1/X i � p ",
103 " F-D f SET g ",
104 " MOD % CLR c ",
105 " � d or \\ x b or * ",
106 " - - + , or + ",
107 " OFF ESC or o DEL DEL or < ",
108 " RM r M+ m ",
109 " +/- ; = RET or = ",
110 "Note: / means 'over' as in fractions ",
111 "F-D converts fraction <--> decimal ",
112 "SET changes settings - use arrow keys ",
113 "Alternative arrow keys - u h j n ",
114 "This program is Public Domain - ",
115 "Certivox, Ireland mscott@indigo.ie "}; /******/
116
117 static char display[]= " MIRACL RATIONAL CALCULATOR V3.2 ";
118 static char status[]= " ";
119 static char oldstat[]= " ";
120
121 static miracl *mip;
122
123 static int erptr=0;
124 static int mmptr=6;
125 static int exptr=10;
126 static int typtr=16;
127 static int stptr[]={22,26,30,34};
128
129 static int dbeg=2;
130 static int dlen=37;
131 static int top=7;
132 static int width=80; /* screen width can be 40 or 80 columns */
133 static char mybuff[40];
134
135 static flash x,y[8],m,t;
136 static flash radeg,loge2,loge10,eps;
137 static int ipt,op[8],prop[8],sp,brkt,lgbase;
138 static BOOL flag,newx,result,hyp,degrees,delim;
139 static int option[]={0,0,0,0};
140
141 /* Device specific code - IBM-PC versions */
142
curser(int x,int y)143 static void curser(int x,int y)
144 { /* position cursor at x,y */
145 union REGS regs;
146 regs.h.ah=2;
147 regs.h.dh=y-1;
148 regs.h.dl=x-1;
149 regs.h.bh=0; /* Video page 0 */
150 int86(0x10,®s,®s); /* Use Dos Interrupt 10h */
151 }
152
screen(void)153 static void screen(void)
154 { /* initialise screen */
155 union REGS regs;
156 regs.h.ah=0x0F; /* get screen mode */
157 regs.h.al=0;
158 int86(0x10,®s,®s);
159 dmode=regs.h.al;
160 if ((dmode&2)!=0) width=80;
161 else width=40;
162 regs.h.ah=6; /* clear screen */
163 regs.h.al=0;
164 regs.h.cl=0;
165 regs.h.ch=0;
166 regs.h.dl=width-1;
167 regs.h.dh=24;
168 regs.h.bh=BGROUND;
169 regs.h.bl=0;
170 int86(0x10,®s,®s);
171 }
172
restore(void)173 static void restore(void)
174 { /* restore situation */
175 union REGS inregs,outregs;
176 inregs.h.ah=0; /* reset initial display mode */
177 inregs.h.al=dmode;
178 int86(0x10,&inregs,&outregs);
179 }
180
apchar(int attr,int x,int y,char ch)181 static void apchar(int attr,int x,int y,char ch)
182 { /* output character with attribute at x,y */
183 union REGS regs;
184 curser(x,y);
185 regs.h.ah=9; /* output a character */
186 regs.h.al=ch;
187 regs.h.bh=0;
188 regs.h.bl=attr;
189 regs.h.cl=1;
190 regs.h.ch=0;
191 int86(0x10,®s,®s);
192 }
193
aprint(int attr,int x,int y,char * text)194 static void aprint(int attr,int x,int y,char *text)
195 { /* attribute print */
196 while (*text!='\0')
197 {
198 apchar(attr,x++,y,*text);
199 text++;
200 }
201 }
202
lclr(int x,int y)203 static void lclr(int x,int y)
204 { /* clear from x,y to end of line */
205 aprint(BGROUND,x,y," ");
206 }
207
cset(int k)208 static void cset(int k)
209 { /* select special character set */
210 return;
211 }
212
gethit(void)213 static int gethit(void)
214 { /* get single keystroke */
215 int ch;
216 ch=getch();
217 if (ch!=0) return ch;
218 ch=getch();
219 if (ch==72) return 'u'; /* transform some useful extended codes */
220 if (ch==75) return 'h';
221 if (ch==77) return 'j';
222 if (ch==80) return 'n';
223 if (ch==83) return 127;
224 return 0;
225 }
226
227 /*** Device independent code ***/
228
arrow(int c)229 static int arrow(int c)
230 { /* check for arrow key *
231 * returns 1 for up, 2 for down, *
232 * 3 for right, 4 for left, else 0 */
233 if (c=='u') return 1;
234 if (c=='n') return 2;
235 if (c=='j') return 3;
236 if (c=='h') return 4;
237 return 0;
238 }
239
instat(int ptr,char * strg)240 static void instat(int ptr,char *strg)
241 { /* insert a status setting into status line */
242 strncpy(&status[ptr],strg,strlen(strg));
243 }
244
getstat(void)245 static void getstat(void)
246 { /* set status line */
247 int i;
248 if (mip->ERNUM) instat(erptr,"ERROR");
249 else instat(erptr," ");
250 if (mip->EXACT) instat(exptr,"EXACT");
251 else instat(exptr," ");
252 if (size(m)!=0) instat(mmptr,"MEM");
253 else instat(mmptr," ");
254 if (mip->RPOINT) instat(typtr,"POINT");
255 else instat(typtr,"FRACT");
256 for (i=0;i<4;i++)
257 instat(stptr[i],settings[i][option[i]]);
258 }
259
setopts(void)260 static void setopts(void)
261 { /* set options */
262 if (option[0]==0) hyp=FALSE;
263 else hyp=TRUE;
264 lgbase=0;
265 if (option[1]==1) lgbase=2;
266 if (option[1]==2) lgbase=10;
267 if (option[2]==0) degrees=FALSE;
268 else degrees=TRUE;
269 mip->IOBASE=10;
270 if (option[3]==1) mip->IOBASE=16;
271 if (option[3]==2) mip->IOBASE=8;
272 if (option[3]==3) mip->IOBASE=2;
273 }
274
show(BOOL force)275 static void show(BOOL force)
276 { /* output display */
277 if (force || strcmp(oldstat,status)!=0)
278 {
279 if (mip->ERNUM) aprint(BLINKING,2,2,status);
280 else aprint(STATCOL,2,2,status);
281 strcpy(oldstat,status);
282 }
283 aprint(BOLD,dbeg,3,display);
284 }
285
clr(void)286 static void clr(void)
287 { /* clear input buffer */
288 mybuff[0]='0';
289 mybuff[1]='\0';
290 ipt=0;
291 delim=FALSE;
292 }
293
just(char * buff)294 static void just(char *buff)
295 { /* justify buff into display (if possible) *
296 * and update status */
297 int i,mp,df;
298 BOOL dot;
299 dot=FALSE;
300 mp=0;
301 while (mp<=dlen && buff[mp]!='\0')
302 {
303 if (buff[mp]=='.') dot=TRUE;
304 if (mp==dlen && !dot) mip->ERNUM=(-1);
305 mp++;
306 }
307 if (mp>dlen) mp=dlen;
308 if (!mip->ERNUM)
309 {
310 df=dlen-mp;
311 for (i=0;i<df;i++) display[i]=' ';
312 for (i=0;i<mp;i++) display[df+i]=buff[i];
313 }
314 display[dlen]='\0';
315 }
316
drawit(void)317 static void drawit(void)
318 { /* Draw calculator */
319 int i,j;
320 char line[40],tline[40],bline[40];
321 cset(1);
322 line[0]=DTLHC;
323 for (i=1;i<38;i++) line[i]=DHORZ;
324 line[38]=DTRHC;
325 line[39]='\0';
326 aprint(ORDINARY,1,1,line);
327 for (i=1;i<22;i++) apchar(ORDINARY,1,1+i,DVERT);
328 line[0]=DBLHC;
329 line[38]=DBRHC;
330 aprint(ORDINARY,1,23,line);
331 for (i=1;i<22;i++) apchar(ORDINARY,39,1+i,DVERT);
332 line[0]=LSIDE; /* draw in the bar */
333 for (i=1;i<38;i++) line[i]=HORZ;
334 line[38]=RSIDE;
335 aprint(ORDINARY,1,4,line);
336 line[0]=tline[0]=bline[0]=SPACE;
337 line[36]=tline[36]=bline[36]=SPACE;
338 line[37]=tline[37]=bline[37]='\0';
339 for (i=1;i<36;i++)
340 {
341 switch (i%5)
342 {
343 case 1 : tline[i]=TLHC;
344 bline[i]=BLHC;
345 line[i]=VERT;
346 break;
347 default: tline[i]=HORZ;
348 bline[i]=HORZ;
349 line[i]=SPACE;
350 break;
351 case 0 : tline[i]=TRHC;
352 bline[i]=BRHC;
353 line[i]=VERT;
354 break;
355 }
356 }
357 for (j=0;j<6;j++)
358 {
359 aprint(ORDINARY,2,5+3*j,tline);
360 aprint(ORDINARY,2,6+3*j,line);
361 aprint(ORDINARY,2,7+3*j,bline);
362 }
363 cset(0);
364 for (j=0;j<6;j++)
365 for (i=0;i<7;i++)
366 aprint(ORDINARY,4+5*i,6+3*j,keys[j][i]);
367 aprint(HELPCOL,2,24,"Type 'H' for help on/off, 'O' to exit");
368 cotstr(x,mip->IOBUFF);
369 just((char *)mip->IOBUFF);
370 getstat();
371 show(TRUE);
372 }
373
next(int ch)374 static BOOL next(int ch)
375 { /* get next digit - returns FALSE if there is a problem */
376 int cv;
377 result=FALSE;
378 if (ipt>=dlen) return FALSE;
379 if (ch=='/' || ch=='.')
380 {
381 if (delim || (ch=='/' && ipt==0)) return FALSE;
382 delim=TRUE;
383 }
384 else
385 {
386 if (ch>='A' && ch<='F') cv=10+(ch-'A');
387 else cv=ch-'0';
388 if (mip->IOBASE<=cv) return FALSE;
389 }
390 if (ipt==0 && ch=='0') clr();
391 else
392 {
393 mybuff[ipt++]=ch;
394 mybuff[ipt]='\0';
395 }
396 just(mybuff);
397 cinstr(x,mybuff);
398 newx=TRUE;
399 return TRUE;
400 }
401
swap(void)402 static void swap(void)
403 { /* swap x with top of stack */
404 flash t;
405 t=x;
406 x=y[sp];
407 y[sp]=t;
408 }
409
prec(int no)410 static int prec(int no)
411 { /* return new operator precedence */
412 return 4*brkt+opp[no];
413 }
414
equals(int no)415 static void equals(int no)
416 { /* perform binary operation */
417 BOOL pop;
418 newx=FALSE;
419 pop=TRUE;
420 while (pop)
421 {
422 if (prec(no)>prop[sp])
423 { /* if higher precedence, keep this one pending */
424 if (sp==top)
425 {
426 mip->ERNUM=(-1);
427 result=FALSE;
428 newx=TRUE;
429 }
430 else sp++;
431 return;
432 }
433 newx=TRUE;
434 if (flag && op[sp]!=3 && op[sp]!=0) swap();
435 switch (op[sp])
436 {
437 case 7: fdiv(x,y[sp],t);
438 ftrunc(t,t,t);
439 fmul(t,y[sp],t);
440 fsub(x,t,x);
441 break;
442 case 6: fpowf(x,y[sp],x);
443 break;
444 case 5: frecip(y[sp],t);
445 fpowf(x,t,x);
446 break;
447 case 4: fdiv(x,y[sp],x);
448 break;
449 case 3: fmul(x,y[sp],x);
450 break;
451 case 2: fsub(x,y[sp],x);
452 break;
453 case 1: fadd(x,y[sp],x);
454 break;
455 case 0: break;
456 }
457 if (sp>0 && (prec(no)<=prop[sp-1])) sp--;
458 else pop=FALSE;
459 }
460 }
461
chekit(int no)462 static void chekit(int no)
463 { /* deal with operator */
464 if (flag && newx) equals(no);
465 else newx=FALSE;
466 flag=ON;
467 copy(x,y[sp]);
468 op[sp]=no;
469 prop[sp]=prec(no);
470 }
471
clrall(void)472 static void clrall(void)
473 { /* clear all */
474 mip->ERNUM=0;
475 zero(x);
476 zero(y[0]);
477 zero(m);
478 sp=0;
479 op[sp]=0;
480 prop[sp]=0;
481 brkt=0;
482 mip->RPOINT=ON;
483 mip->EXACT=TRUE;
484 }
485
act(int p,int q)486 static BOOL act(int p,int q)
487 { /* act on selected key */
488 int k,n,c;
489 aprint(PRESSED,4+5*p,6+3*q,keys[q][p]);
490 switch(p+7*q)
491 {
492 case 0: if (degrees) fmul(x,radeg,x);
493 if (hyp) fsinh(x,x);
494 else fsin(x,x);
495 newx=TRUE;
496 break;
497 case 1: if (degrees) fmul(x,radeg,x);
498 if (hyp) fcosh(x,x);
499 else fcos(x,x);
500 newx=TRUE;
501 break;
502 case 2: if (degrees) fmul(x,radeg,x);
503 if (hyp) ftanh(x,x);
504 else ftan(x,x);
505 newx=TRUE;
506 break;
507 case 3: if (lgbase>0)
508 {
509 n=size(x);
510 if (abs(n)<MR_TOOBIG)
511 {
512 convert(lgbase,x);
513 if (n<0) frecip(x,x);
514 fpower(x,abs(n),x);
515 newx=TRUE;
516 break;
517 }
518 if (lgbase==2) fmul(x,loge2,x);
519 if (lgbase==10) fmul(x,loge10,x);
520 }
521 fexp(x,x);
522 newx=TRUE;
523 break;
524 case 4: mip->RPOINT=!mip->RPOINT;
525 newx=TRUE;
526 break;
527 case 5: clrall();
528 newx=TRUE;
529 break;
530 case 6: return TRUE;
531 case 7: if (hyp) fasinh(x,x);
532 else fasin(x,x);
533 if (degrees) fdiv(x,radeg,x);
534 newx=TRUE;
535 break;
536 case 8: if (hyp) facosh(x,x);
537 else facos(x,x);
538 if (degrees) fdiv(x,radeg,x);
539 newx=TRUE;
540 break;
541 case 9: if (hyp) fatanh(x,x);
542 else fatan(x,x);
543 if (degrees) fdiv(x,radeg,x);
544 newx=TRUE;
545 break;
546 case 10: flog(x,x);
547 if (lgbase==2) fdiv(x,loge2,x);
548 if (lgbase==10) fdiv(x,loge10,x);
549 newx=TRUE;
550 break;
551 case 11: newx=TRUE;
552 k=3;
553 forever
554 {
555 aprint(INVER,2+stptr[k],2,settings[k][option[k]]);
556 curser(2+stptr[k],2);
557 c=arrow(gethit());
558 if (c==1)
559 {
560 if (option[k]==nops[k]) option[k]=0;
561 else option[k]+=1;
562 continue;
563 }
564 aprint(STATCOL,2+stptr[k],2,settings[k][option[k]]);
565 if (c==0 || c==2) break;
566 if (c==4 && k>0) k--;
567 if (c==3 && k<3) k++;
568 }
569 setopts();
570 break;
571 case 12: chekit(7);
572 break;
573 case 13: result=FALSE;
574 if (ipt==0) break;
575 ipt--;
576 mybuff[ipt]='\0';
577 if (ipt==0) clr();
578 just(mybuff);
579 cinstr(x,mybuff);
580 newx=TRUE;
581 break;
582 case 14: if (!next('7')) putchar(BELL);
583 break;
584 case 15: if (!next('8')) putchar(BELL);
585 break;
586 case 16: if (!next('9')) putchar(BELL);
587 break;
588 case 17: chekit(6);
589 break;
590 case 18: chekit(5);
591 break;
592 case 19: chekit(4);
593 break;
594 case 20: copy(m,x);
595 newx=TRUE;
596 break;
597 case 21: if (!next('4')) putchar(BELL);
598 break;
599 case 22: if (!next('5')) putchar(BELL);
600 break;
601 case 23: if (!next('6')) putchar(BELL);
602 break;
603 case 24: fmul(x,x,x);
604 newx=TRUE;
605 break;
606 case 25: froot(x,2,x);
607 newx=TRUE;
608 break;
609 case 26: chekit(3);
610 break;
611 case 27: brkt=0;
612 chekit(0);
613 flag=OFF;
614 fadd(m,x,m);
615 newx=TRUE;
616 break;
617 case 28: if (!next('1')) putchar(BELL);
618 break;
619 case 29: if (!next('2')) putchar(BELL);
620 break;
621 case 30: if (!next('3')) putchar(BELL);
622 break;
623 case 31: frecip(x,x);
624 newx=TRUE;
625 break;
626 case 32: fpi(x);
627 newx=TRUE;
628 break;
629 case 33: chekit(2);
630 break;
631 case 34: negify(x,x);
632 newx=TRUE;
633 break;
634 case 35: if (!next('0')) putchar(BELL);
635 break;
636 case 36: if (!next('/')) putchar(BELL);
637 break;
638 case 37: if (!next('.')) putchar(BELL);
639 break;
640 case 38: if (ipt>0)
641 {
642 putchar(BELL);
643 result=FALSE;
644 }
645 else
646 {
647 zero(x);
648 brkt+=1;
649 newx=TRUE;
650 }
651 break;
652 case 39: if (brkt>0)
653 {
654 chekit(0);
655 brkt-=1;
656 }
657 else
658 {
659 putchar(BELL);
660 result=FALSE;
661 }
662 break;
663 case 40: chekit(1);
664 break;
665 case 41: brkt=0;
666 equals(0);
667 flag=OFF;
668 break;
669 }
670 return FALSE;
671 }
672
main()673 int main()
674 { /* MIRACL rational calculator */
675 int i,j,k,p,q,c,hpos;
676 BOOL over,help;
677 screen();
678 #if MIRACL==16
679 mip=mirsys(10,0); /*** 16-bit computer ***/
680 #else
681 mip=mirsys(6,0); /*** 32-bit computer ***/
682 #endif
683 mip->ERCON=TRUE;
684 x=mirvar(0);
685 for (i=0;i<=top;i++) y[i]=mirvar(0);
686 m=mirvar(0);
687 t=mirvar(0);
688 radeg=mirvar(0);
689 loge2=mirvar(0);
690 loge10=mirvar(0);
691 eps=mirvar(0);
692 mip->pi=mirvar(0);
693 cinstr(mip->pi,cpi); /* read in constants */
694 fpmul(mip->pi,1,180,radeg);
695 cinstr(loge2,clg2);
696 cinstr(loge10,clg10);
697 cinstr(eps,ceps);
698 help=OFF;
699 show(TRUE);
700 p=6;
701 q=0;
702 flag=OFF;
703 newx=OFF;
704 over=FALSE;
705
706
707 setopts();
708 clrall();
709 drawit();
710 while (!over)
711 { /* main loop */
712 if (mip->ERNUM)
713 {
714 aprint(ORDINARY,4+5*p,6+3*q,keys[q][p]);
715 p=5,q=0;
716 }
717 if (width==80 || !help)
718 {
719 aprint(INVER,4+5*p,6+3*q,keys[q][p]);
720 curser(1,24);
721 c=gethit();
722 aprint(ORDINARY,4+5*p,6+3*q,keys[q][p]);
723 }
724 else while ((c=gethit())!='H') ;
725 result=TRUE;
726 if ((k=arrow(c))!=0)
727 { /* arrow key hit */
728 if (k==1 && q>0) q--;
729 if (k==2 && q<5) q++;
730 if (k==3 && p<6) p++;
731 if (k==4 && p>0) p--;
732 continue;
733 }
734 if (c=='H')
735 { /* switch help on/off */
736 help=!help;
737 for (i=1;i<=24;i++)
738 {
739 if (width==80) hpos=41;
740 else hpos=1;
741 if (help) aprint(HELPCOL,hpos,i,htext[i-1]);
742 else lclr(hpos,i);
743 }
744 if (width==40 && !help) drawit();
745 continue;
746 }
747 if (c>='A' && c<='F')
748 { /* hex only */
749 if (!next(c)) putchar(BELL);
750 else show(FALSE);
751 continue;
752 }
753 for (j=0;j<6;j++)
754 for (i=0;i<7;i++)
755 if (c==qkeys[j][i]) p=i,q=j,c=' ';
756 if (c==8 || c==127) p=6,q=1,c=' '; /* aliases */
757 if (c==',' || c=='a') p=5,q=5,c=' ';
758 if (c=='O' || c==ESC) p=6,q=0,c=' ';
759 if (c==13) p=6,q=5,c=' ';
760 if (c=='[' || c=='{') p=3,q=5,c=' ';
761 if (c==']' || c=='}') p=4,q=5,c=' ';
762 if (c=='d') p=5,q=2,c=' ';
763 if (c=='b') p=5,q=3,c=' ';
764 if (c=='^') p=3,q=2,c=' ';
765 if (c==' ') over=act(p,q);
766 else continue;
767 absol(x,t);
768 if (fcomp(t,eps)<0) zero(x);
769 if (result)
770 { /* output result to display */
771 cotstr(x,mip->IOBUFF);
772 just((char *)mip->IOBUFF);
773 if (mip->ERNUM<0)
774 { /* convert to radix and try again */
775 mip->ERNUM=0;
776 mip->RPOINT=ON;
777 cotstr(x,mip->IOBUFF);
778 putchar(BELL);
779 just((char *)mip->IOBUFF);
780 }
781 clr();
782 }
783 if (newx)
784 { /* update display */
785 getstat();
786 show(FALSE);
787 }
788 }
789 curser(1,24);
790 restore();
791 return 0;
792 }
793
794