Fix to Comet Halley program

Frank Dibbell canopus at amdahl.UUCP
Fri Apr 12 03:56:20 AEST 1985


Alas, a small bug was discovered in the Halley's Comet progam which
I posted last week.  The program works fine for every year but 1986!
For 1986, it will give random results.  To fix the problem, make
the following change:

In the section titled: /* CALCULATE COMET POSITION         */

   change from:  if (Y > 1986) Z = 1984,  S = 0;
   change to  :  if (Y >= 1986) Z = 1984,  S = 0;

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

All of our systems have different attributes, and its difficult, if not
impossible, to produce a single version of a program that will run on
everyone's machine.  With this in mind, I will pass along some helpful
hints supplied to me by others, when dealing with halley.c:

1.  Some systems require the following include to define "tolower()":
    #include <ctype.h>

2.  On some systems the "tolower()" function is defined only for upper
    case.  In order to exit the halley program, then, the following
    code modification will be required:

change from:      if (c = (tolower(getchar())) != 'x')  continue;
                  else  break;


change to  :      c = getchar();
                  if (isupper(c))
                          c = tolower(c);
                  if (c != 'x' )  continue;
                  else break;


If anything anything else pops up, I'll probably put it into
net.sources.bugs where it belongs!
-- 
Frank Dibbell     (408-746-6493)                 {whatever}!amdahl!canopus
[R.A. 6h 22m 30s  Dec. -52d 36m]                 [Generic disclaimer.....]



More information about the Comp.sources.unix mailing list