home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / c / 18915 < prev    next >
Encoding:
Text File  |  1992-12-27  |  1.6 KB  |  37 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!seas.smu.edu!utacfd.uta.edu!rwsys!sneaky!gordon
  3. From: gordon@sneaky.lonestar.org (Gordon Burditt)
  4. Subject: Re: speed?  double vs. float.  math.h??
  5. Message-ID: <BzxL4C.3qz@sneaky.lonestar.org>
  6. Organization: Gordon Burditt
  7. References: <1hh801INNab1@agate.berkeley.edu>
  8. Date: Sun, 27 Dec 1992 18:38:31 GMT
  9. Lines: 26
  10.  
  11. >     I'm currently writing a C program where it needs to do lots and lots of
  12. >trig calculations.  But I would like the program to run really really fast.
  13. >So I'm concerned about the speed at which the calculations are carried out.
  14.  
  15. Be careful, you might be shooting yourself in the foot.  *MEASURE*
  16. the differences.  
  17.  
  18. >Trying to make the program run fast, I would like to have only float 
  19. >variables, instead of doubles, in my program.  But in the standard math 
  20. >library, all the functions take in arguments and return values in the type 
  21. >double.  So, what should I do?  First of all, should I even be concerned 
  22.  
  23. Taking, for example, the 486DX, mostly because I have the book
  24. handy, the only instructions that are affected by the precision
  25. control bits are add, subtract, multiply, divide, and square root
  26. (not the trig functions, etc.).  Only the divide instruction mentions 
  27. timing being different based on precision control.  Storing a real 
  28. number is 1 clock different in 32 bits vs. 64 bits, but storing an 
  29. 80-bit real is one clock FASTER than storing a 32-bit real!  
  30.  
  31. If the compiler is generating actual code to do conversions between
  32. float and double, a few clocks saved on stores may be overwhelmed
  33. by the conversion code.
  34.  
  35.                         Gordon L. Burditt
  36.                         sneaky.lonestar.org!gordon
  37.