Path: utzoo!attcan!uunet!samsung!usc!ucsd!ucbvax!cs.hull.ac.uk!rst From: rst@cs.hull.ac.uk (Rob Turner) Newsgroups: comp.lang.c Subject: Floating Point Arithmetic Message-ID: <27095.9010261638@olympus.cs.hull.ac.uk> Date: 26 Oct 90 16:38:04 GMT Sender: daemon@ucbvax.BERKELEY.EDU Lines: 21 (Henry Spencer) writes: >In general, you should use 'double' for all floating point arithmetic I agree with this, although 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. 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. I believe that the situation has changed with ANSI C, and none of these conversions are performed. Robert Turner Department of Computer Science, University of Hull, England.