From 11da511c784eca003deb90c23570f0873954e0de Mon Sep 17 00:00:00 2001 From: Duncan Wilkie Date: Sat, 18 Nov 2023 06:11:09 -0600 Subject: Initial commit. --- ic-reals-6.3/tests/tan_R_digit.c | 55 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 ic-reals-6.3/tests/tan_R_digit.c (limited to 'ic-reals-6.3/tests/tan_R_digit.c') diff --git a/ic-reals-6.3/tests/tan_R_digit.c b/ic-reals-6.3/tests/tan_R_digit.c new file mode 100644 index 0000000..18bdc2e --- /dev/null +++ b/ic-reals-6.3/tests/tan_R_digit.c @@ -0,0 +1,55 @@ +#include +#include "real.h" +#include + +/* + * This is the same as the tan_R test but shows how to retrieve digits + * from a real incrementally. + */ +main(int argc, char *argv[]) +{ + Real x, y; + double f; + Real makeRealSignCNQInt(Sign, char *, int, int, int); + mpz_t digits; + Sign sign; + Digit digit; + int count; + + MyName = argv[0]; + + if (argc != 7) { + fprintf(stderr, "%s \n", MyName); + exit(1); + } + + initReals(); + + y = makeRealSignCNQInt( + atoi(argv[1]), /* sign */ + argv[2], /* c */ + atoi(argv[3]), /* n */ + atoi(argv[4]), /* a */ + atoi(argv[5])); /* b */ + + print_R_Dec(y, atoi(argv[6])); + printf("\n"); + f = realToDouble(y); + printf("x=%f\n",f); + + x = tan_R(y); + + print_R_Dec(x, atoi(argv[6])); + printf("\n"); + printf("tan(x)=%f\n", tan(f)); + + mpz_init(digits); + retrieveInfo(x, &sign, &count, digits); + + printf("%s ", signToString(sign)); + while (count > 0) { + digit = takeDigit(&count, digits); + printf("%s ", digitToString(digit)); + } + printf("\n"); +} -- cgit v1.2.3