35 lines
618 B
C
35 lines
618 B
C
|
#include <stdio.h>
|
||
|
#include "gm.h"
|
||
|
void ErrorHandler(int,int);
|
||
|
void main(void);
|
||
|
|
||
|
void ErrorHandler(code,ref)
|
||
|
int code,ref;
|
||
|
{
|
||
|
char serr[15],sfun[32];
|
||
|
ErrorName(serr, code);
|
||
|
FunctionName(sfun, ref);
|
||
|
printf("%s error in function %s\n",serr,sfun);
|
||
|
}
|
||
|
|
||
|
void main()
|
||
|
{
|
||
|
DEC da, *a=&da, db, *b=&db, dc, *c=&dc, *p;
|
||
|
|
||
|
SetMathErrVector(ErrorHandler);
|
||
|
|
||
|
ZeroDecimal(a);
|
||
|
ZeroDecimal(b);
|
||
|
ZeroDecimal(c);
|
||
|
|
||
|
dprintf("First number: ");
|
||
|
dscanf("%.2t",a);
|
||
|
dprintf("Second number: ");
|
||
|
dscanf("%.2t",b);
|
||
|
p = DivideDecimalAndRound(c,a,b,2);
|
||
|
if (p)
|
||
|
dprintf("%t / %t = %t\n",a,b,c);
|
||
|
else
|
||
|
dprintf("Division failed.\n");
|
||
|
}
|