home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!sdd.hp.com!elroy.jpl.nasa.gov!usc!srhqla!quest!kdq
- From: kdq@quest.UUCP (Kevin D. Quitt)
- Newsgroups: comp.lang.c
- Subject: Re: speed? double vs. float. math.h??
- Message-ID: <PRmewB2w165w@quest.UUCP>
- Date: Sat, 26 Dec 92 11:31:48 PST
- References: <1hh801INNab1@agate.berkeley.edu>
- Reply-To: srhqla!quest!kdq
- Organization: Job quest (805) 251-8210, So Cal: (800) 400-8210
- Lines: 30
-
- 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.
- > 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?
-
- It depends on your machine. If your machine uses IEEE format
- floating point, and has hardware to do the calculations, then the
- internal calculation format is probably always double, if not long
- double. (Motorola's FPUs use the 96bit long double format. Intel's
- FPUs use double format). You might want to benchmark your program
- per:
-
- typdef float FP;
- and define all your floats as type FP. Next time, use:
-
- typedef double FP;
-
-
- _
- Kevin D. Quitt 96.37% of all statistics are made up. srhqla!quest!kdq
-