Path: utzoo!attcan!uunet!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.lang.c Subject: Re: Floating Point Arithmetic Message-ID: <490@taumet.com> Date: 27 Oct 90 16:48:20 GMT References: <27095.9010261638@olympus.cs.hull.ac.uk> Organization: Taumetric Corporation, San Diego Lines: 32 rst@cs.hull.ac.uk (Rob Turner) writes: >[ ... ] it took me a fair while to get over the >natural hurdle of always prefering to use float because float >arithmetic 'must be faster' than double. If FP arithmetic is done in software and the software does both float and double arithmetic, float is generally faster. With hardware floating-point, there is usually no difference, since the hardware converts to its internal form and back. >I am under the impression >that in K&R C (which I have used to do most of my C programming), all >floating point computation is performed in double precision mode >anyway, so the compiler ends up having to convert floats to doubles >before you do the sums, then translate back into floats afterwards. >Depending on the floating point format, these conversions take up >varying amounts of time. Similarly, float parameters are passed as >doubles. True; and you cannot predict whether conversion to/from float is faster or slower than conversion to/from double on an unkonwn system, nor whether the conversion time is compensated for by the difference, if any, in float vs double arithmetic speed. >I believe that the situation has changed with ANSI C, and >none of these conversions are performed. Not quite. ANSI C allows but does not require arithmetic on float types to be performed without conversion to double. -- Steve Clamage, TauMetric Corp, steve@taumet.com