36 lines
617 B
C
36 lines
617 B
C
|
#include <stdio.h>
|
||
|
#include "gm.h"
|
||
|
void main(void);
|
||
|
|
||
|
void main()
|
||
|
{
|
||
|
DEC da, *a=&da, db, *b=&db;
|
||
|
DEC *f;
|
||
|
char s[30];
|
||
|
int prec;
|
||
|
|
||
|
do {
|
||
|
printf("Type a number: ");
|
||
|
scanf("%s",s);
|
||
|
f = ConvAsciiToDecimal(a,s);
|
||
|
} while (f == GM_NULL);
|
||
|
|
||
|
printf("Round to how many decimal places? ");
|
||
|
scanf("%d", &prec);
|
||
|
|
||
|
f = RoundDecimal(b, a, prec);
|
||
|
if (f) {
|
||
|
ConvDecimalToAscii(s, b);
|
||
|
printf(" Rounding yields %s\n", s);
|
||
|
}
|
||
|
else
|
||
|
printf("Rounding failed\n");
|
||
|
|
||
|
f = TruncateDecimal(b, a, prec);
|
||
|
if (f) {
|
||
|
ConvDecimalToAscii(s, b);
|
||
|
printf("Truncation yields %s\n", s);
|
||
|
}
|
||
|
else
|
||
|
printf("Truncating failed\n");
|
||
|
}
|