44 lines
724 B
C
44 lines
724 B
C
|
#include <stdio.h>
|
||
|
#include "gm.h"
|
||
|
void printres(char *,DEC *);
|
||
|
void main(void);
|
||
|
|
||
|
void main()
|
||
|
{
|
||
|
DEC *x, *y, *p;
|
||
|
|
||
|
x = AllocateDecimal();
|
||
|
y = AllocateDecimal();
|
||
|
|
||
|
p = ConvAsciiToDecimal(x, "19.88");
|
||
|
printres("x = ", p);
|
||
|
p = AbsoluteDecimal(y, x);
|
||
|
printres("abs(x) = ", p);
|
||
|
p = ChangeSignDecimal(y, x);
|
||
|
printres("-x = ", p);
|
||
|
p = FractionDecimal(y, x);
|
||
|
printres("fract(x) = ", p);
|
||
|
p = IntegerPartDecimal(y, x);
|
||
|
printres("int(x) = ", p);
|
||
|
p = SquareRootDecimal(y, x);
|
||
|
printres("sqrt(x) = ", p);
|
||
|
|
||
|
FreeDecimal(x);
|
||
|
FreeDecimal(y);
|
||
|
}
|
||
|
|
||
|
void printres(str, pd)
|
||
|
char *str;
|
||
|
DEC *pd;
|
||
|
{
|
||
|
char sd[22];
|
||
|
|
||
|
printf("%12s", str);
|
||
|
if (pd) {
|
||
|
ConvDecimalToAscii(sd, pd);
|
||
|
printf("%s\n", sd);
|
||
|
}
|
||
|
else
|
||
|
printf("undefined\n");
|
||
|
}
|