home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / c / 19610 < prev    next >
Encoding:
Internet Message Format  |  1993-01-12  |  2.1 KB

  1. Path: sparky!uunet!math.fu-berlin.de!news.th-darmstadt.de!adams
  2. From: adams@pdv2.fmr.maschinenbau.th-darmstadt.de (Adams)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: speed?  double vs. float.  math.h??
  5. Date: 13 Jan 93 01:14:54
  6. Organization: TH-Darmstadt
  7. Lines: 33
  8. Distribution: world
  9. Message-ID: <ADAMS.93Jan13011454@PDV2.pdv2.fmr.maschinenbau.th-darmstadt.de>
  10. References: <1hh801INNab1@agate.berkeley.edu>
  11. NNTP-Posting-Host: pdv2.fmr.maschinenbau.th-darmstadt.de
  12. In-reply-to: c60b-3hu@web-3c.berkeley.edu's message of 26 Dec 1992 09:17:53 GMT
  13.  
  14. In article <1hh801INNab1@agate.berkeley.edu> c60b-3hu@web-3c.berkeley.edu (Paul Hsu) writes:
  15.  
  16. >    I'm currently writing a C program where it needs to do lots and lots of
  17. >   trig calculations.  But I would like the program to run really really fast.
  18.  
  19.  
  20. Perhaps, find a better algorithm. For some problems requiring lots
  21. of trigonometric calculation better algorithms are known
  22. (FFT -> DFFT)
  23.  
  24. >   So I'm concerned about the speed at which the calculations are carried out.
  25. >   Trying to make the program run fast, I would like to have only float 
  26. >   variables, instead of doubles, in my program.  But in the standard math 
  27. >   library, all the functions take in arguments and return values in the type 
  28. >   double.  So, what should I do?  First of all, should I even be concerned 
  29. >   about the speed difference between doing calculations in float and doing the
  30. >   calculations in doubles?  If yes, how should I go about in making the math 
  31. >   functions to accept and return floats?  Casting them won't help....  it'll 
  32. >   only take more time in the type conversion.  Any suggestion?
  33.  
  34. As for most hardware (or micro code) implementations of floating point,
  35. double or extended double are standard, calculations done
  36. in float require additional [!] cycles to convert values to double
  37. and results back to float ;-<.
  38.  
  39. I would be concerned about function call overhead. Therefore I would
  40. prefer a compiler able to generate inline code accessing FP-hardware
  41. in a direct manner insteadt via library call.
  42. (GCC does this by special include files like math-68881.h, 
  43. SUN's cc on SUN3 do it without support by special include files.)
  44.  
  45. best adams
  46.  
  47.