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