home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!seas.smu.edu!utacfd.uta.edu!rwsys!sneaky!gordon
- From: gordon@sneaky.lonestar.org (Gordon Burditt)
- Subject: Re: speed? double vs. float. math.h??
- Message-ID: <BzxL4C.3qz@sneaky.lonestar.org>
- Organization: Gordon Burditt
- References: <1hh801INNab1@agate.berkeley.edu>
- Date: Sun, 27 Dec 1992 18:38:31 GMT
- Lines: 26
-
- > 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.
-
- Be careful, you might be shooting yourself in the foot. *MEASURE*
- the differences.
-
- >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
-
- Taking, for example, the 486DX, mostly because I have the book
- handy, the only instructions that are affected by the precision
- control bits are add, subtract, multiply, divide, and square root
- (not the trig functions, etc.). Only the divide instruction mentions
- timing being different based on precision control. Storing a real
- number is 1 clock different in 32 bits vs. 64 bits, but storing an
- 80-bit real is one clock FASTER than storing a 32-bit real!
-
- If the compiler is generating actual code to do conversions between
- float and double, a few clocks saved on stores may be overwhelmed
- by the conversion code.
-
- Gordon L. Burditt
- sneaky.lonestar.org!gordon
-