/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ /* From input file "decimals.p" */ #include /* decimals: determine the number of decimal places in a real number Dr. Thomas D. Schneider National Institutes of Health National Cancer Institute Center for Cancer Research Nanobiology Program Molecular Information Theory Group Frederick, Maryland 21702-1201 toms@ncifcrf.gov permanent email: toms@alum.mit.edu (use only if first address fails) http://www.ccrnp.ncifcrf.gov/~toms/ */ /* end of program */ /* begin module version */ #define version 1.01 /* of decimals.p 2006 Sep 24 2006 Sep 24, 1.01: clean documentation 2006 Sep 24, 1.00: origin */ #define updateversion 1.00 /* defines lowest acceptable current parameter file */ /* end module version */ /* begin module describe.decimals */ /* name decimals: determine the number of decimal places in a real number synopsis decimals(decimalsp: in, output: out) files decimalsp: parameters to control the program. The file must contain the following parameters, one per line: parameterversion: The version number of the program. This allows the user to be warned if an old parameter file is used. output: messages to the user description Determine the number of decimal places that a real number can hold. This is done by repeatedly dividing by 2 until the number becomes zero. examples documentation see also author Thomas Dana Schneider bugs technical notes */ /* end module describe.decimals */ Static _TEXT decimalsp; /* file used by this program */ Static jmp_buf _JL1; /* begin module halt */ Static Void halt() { /* stop the program. the procedure performs a goto to the end of the program. you must have a label: label 1; declared, and also the end of the program must have this label: 1: end. examples are in the module libraries. this is the only goto in the delila system. */ printf(" program halt.\n"); longjmp(_JL1, 1); } /* end module halt version = 'delmod 6.16 84 mar 12 tds/gds'; */ /* begin module decimals.themain */ Static Void themain(decimalsp) _TEXT *decimalsp; { /* the main procedure of the program */ double parameterversion; /* parameter version number */ double x = 1.0; /* the number */ double p; /* previous x */ printf("decimals %4.2f\n", version); if (*decimalsp->name != '\0') { if (decimalsp->f != NULL) decimalsp->f = freopen(decimalsp->name, "r", decimalsp->f); else decimalsp->f = fopen(decimalsp->name, "r"); } else rewind(decimalsp->f); if (decimalsp->f == NULL) _EscIO2(FileNotFound, decimalsp->name); RESETBUF(decimalsp->f, Char); fscanf(decimalsp->f, "%lg%*[^\n]", ¶meterversion); getc(decimalsp->f); if ((long)floor(100 * parameterversion + 0.5) < (long)floor(100.0 + 0.5)) { printf("You have an old parameter file!\n"); halt(); } while (x > 0) { printf("% .1E\n", x); x /= 2.0; } } /* end module decimals.themain */ main(argc, argv) int argc; Char *argv[]; { PASCAL_MAIN(argc, argv); if (setjmp(_JL1)) goto _L1; decimalsp.f = NULL; strcpy(decimalsp.name, "decimalsp"); themain(&decimalsp); _L1: if (decimalsp.f != NULL) fclose(decimalsp.f); exit(EXIT_SUCCESS); } /* End. */