# HG changeset patch # User jwe # Date 1127497970 0 # Node ID 66ec063e2f4f627a2144ba826de564868eadffe6 # Parent 6a4f8772393293f2f1a8308e55d38b8cb0b2d52b [project @ 2005-09-23 17:52:49 by jwe] diff -r 6a4f87723932 -r 66ec063e2f4f libcruft/ChangeLog --- a/libcruft/ChangeLog Fri Sep 23 16:42:30 2005 +0000 +++ b/libcruft/ChangeLog Fri Sep 23 17:52:50 2005 +0000 @@ -1,3 +1,7 @@ +2005-09-23 John W. Eaton + + * misc/machar.c: Restore test code. + 2005-09-15 John W. Eaton * misc/quit.h Rename all win32_ symbols to w32. Change all uses. diff -r 6a4f87723932 -r 66ec063e2f4f libcruft/misc/machar.c --- a/libcruft/misc/machar.c Fri Sep 23 16:42:30 2005 +0000 +++ b/libcruft/misc/machar.c Fri Sep 23 17:52:50 2005 +0000 @@ -4,7 +4,9 @@ #include +#ifndef TEST #include "f77-fcn.h" +#endif /* @@ -364,6 +366,8 @@ } +#ifndef TEST + F77_RET_T F77_FUNC (machar, MACHAR) (REAL *xmin, REAL *xmax, REAL *epsneg, REAL *eps, REAL *log10_ibeta) @@ -390,3 +394,79 @@ F77_RETURN (0) } + +#else + + +/* + +This program prints hardware-determined double-precision machine +constants obtained from rmachar. Dmachar is a C translation of the +Fortran routine MACHAR from W. J. Cody, "MACHAR: A subroutine to +dynamically determine machine parameters". TOMS (14), 1988. + +Descriptions of the machine constants are given in the prologue +comments in rmachar. + +Subprograms called + + rmachar + +Original driver: Richard Bartels, October 16, 1985 + +Modified by: W. J. Cody + July 26, 1988 + +*/ +int +main (void) +{ + + int ibeta, iexp, irnd, it, machep, maxexp, minexp, negep, ngrd; + + int i; + + REAL eps, epsneg, xmax, xmin; + + union wjc + { + long int jj[REALSIZE]; + REAL xbig; + } uval; + + rmachar (&ibeta, &it, &irnd, &ngrd, &machep, &negep, &iexp, + &minexp, &maxexp, &eps, &epsneg, &xmin, &xmax); + + printf (PREC); + printf (" precision MACHAR constants\n"); + printf ("ibeta = %d\n", ibeta); + printf ("it = %d\n", it); + printf ("irnd = %d\n", irnd); + printf ("ngrd = %d\n", ngrd); + printf ("machep = %d\n", machep); + printf ("negep = %d\n", negep); + printf ("iexp = %d\n", iexp); + printf ("minexp = %d\n", minexp); + printf ("maxexp = %d\n", maxexp); + +#define DISPLAY(s, x) \ + do \ + { \ + uval.xbig = x ; \ + printf (s); \ + printf (" %24.16e ", (double) x) ; \ + for (i = 0; i < REALSIZE; i++) \ + printf (" %9X ", uval.jj[i]) ; \ + printf ("\n"); \ + } \ + while (0) + + DISPLAY ("eps ", eps); + DISPLAY ("epsneg", epsneg); + DISPLAY ("xmin ", xmin); + DISPLAY ("xmax ", xmax); + + return 0; +} + +#endif