home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / pascal / 7802 < prev    next >
Encoding:
Internet Message Format  |  1993-01-02  |  1.3 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!wupost!emory!ogicse!qiclab!leonard
  2. From: leonard@qiclab.scn.rain.com (Leonard Erickson)
  3. Newsgroups: comp.lang.pascal
  4. Subject: Re: powers in TURBO pascal
  5. Message-ID: <1993Jan2.171253.10580@qiclab.scn.rain.com>
  6. Date: 2 Jan 93 17:12:53 GMT
  7. Article-I.D.: qiclab.1993Jan2.171253.10580
  8. References: <30DEC92.02825818.0033@music.mus.polymtl.ca> <dmurdoch.262.725736007@mast.queensu.ca> <1992Dec30.174246.2523@news.uni-stuttgart.de> <1992Dec31.122326.7404@qiclab.scn.rain.com> <1993Jan1.004310.9816@ac.dal.ca>
  9. Reply-To: Leonard.Erickson@f51.n105.z1.fidonet.org
  10. Organization: SCN Research/Qic Laboratories of Tigard, Oregon.
  11. Lines: 29
  12.  
  13. chip@ac.dal.ca writes:
  14.  
  15. >> Function Power(a,b:real):real;
  16. >> begin
  17. >> {messy code goes here!}
  18. >> end;
  19.  
  20. >NOTE:
  21. > y    y * LN(x)
  22. >x  = e
  23.  
  24. >Therefore:
  25.  
  26. >FUNCTION Power(Base, Power) : REAL;
  27. >BEGIN
  28. >  EXP(Power * LN(Base));
  29. >END;
  30.  
  31. >That's the messy code....
  32.  
  33. That's also code that loses a *lot* of precision, and will crash on legal
  34. values of base and power because LN(Base) may yield a value that EXP can't
  35. deal with.
  36.  
  37. -- 
  38. Leonard Erickson              leonard@qiclab.scn.rain.com
  39. CIS: [70465,203]             70465.203@compuserve.com
  40. FIDO:   1:105/51     Leonard.Erickson@f51.n105.z1.fidonet.org
  41. (The CIS & Fido addresses are preferred)
  42.