home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / os / msdos / programm / 11494 < prev    next >
Encoding:
Text File  |  1992-12-20  |  2.3 KB  |  49 lines

  1. Newsgroups: comp.os.msdos.programmer
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!sdd.hp.com!ux1.cso.uiuc.edu!news.cso.uiuc.edu!uxa.cso.uiuc.edu!macg9505
  3. From: macg9505@uxa.cso.uiuc.edu (Michael Alan Corn)
  4. Subject: Floating point error:Stack Overflow - Huh?
  5. Message-ID: <BzFu1z.MvJ@news.cso.uiuc.edu>
  6. Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
  7. Organization: University of Illinois at Urbana
  8. Date: Fri, 18 Dec 1992 04:34:46 GMT
  9. Lines: 38
  10.  
  11.  
  12. Hello,
  13.         I was hoping that someone could provide a good explanation of an
  14.         error that BC3.1++ was reporting. After calling a certain function
  15.         around 12 or so times, the program terminates with
  16.         "Floating point error: Stack fault".  This is on a 386 with no co
  17.         -processor installed, I rely upon the emulation code of the compiler.
  18.         The function in question computes a number of parameters related to the
  19.         moon (position, distance, etc..), It is VERY math intensive, requiring
  20.         around 160 lines of code consisting of almost all trig functions.
  21.         On top of that I declare all the variables to be long doubles, to
  22.         maximize accuracy.  Thr routine worked fine until I added the following
  23.         code that computes the illuminated fraction of the moons disk, its
  24.         distance in earth radii and kilometers, and its geocentric diameter.
  25.         The added code is below. The function returns (as I have left it below)
  26.         a reference to a structure.  The values computed are dead nuts, so I'm
  27.         baffled what is going wrong.  The manual says "This error does not
  28.         normally occur ...." but really provides no good explanation or method
  29.         to fix this.  Any help would be greatly appreciated, and indebt me
  30.         and any future generations for eternity. Mike
  31. macg9505@uxa.cso.uiuc.edu
  32. :
  33.  
  34. NB: the rad variable converts degrees to radians and vice-versa
  35.  
  36. long double d = acosl(cosl(moon.gamma*rad - sunlong*rad)*cosl(moon.beta*rad));
  37. long double i = (180 - (d/rad) - (0.1468 * ((1-0.0549*sinl(Mprime))/(1- 0.0167*sinl(M))) * sinl(d)));
  38.  
  39.                    moon.illum_frac = (1 + cosl(i*rad))/2;
  40.                    moon.dist_e_radii = 1/sinl(moon.TT*rad);
  41.                    moon.dist_klm = 6378.14/sinl(moon.TT*rad);
  42.                    moon.geocen_diam = 0.272476 * moon.TT*3600;//convert to seconds of arc
  43.    Moonptr ip;
  44.    Moonref ir;
  45.    ip = &moon;
  46.    ir = &ip;
  47.         return ir;
  48. }
  49.