Floating Point Arithmetic

Doug Gwyn gwyn at smoke.brl.mil
Wed Nov 7 20:08:43 AEST 1990


In article <27095.9010261638 at olympus.cs.hull.ac.uk> rst at cs.hull.ac.uk (Rob Turner) writes:
><henry at zoo.toronto.edu> (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.

Interestingly, that is not always true, especially using IEEE FP chips.

>I believe that the situation has changed with ANSI C, and
>none of these conversions are performed.

Conversion to double is not REQUIRED but it is PERMITTED.

The real reason for avoiding floats is that unless you already know all
about this stuff, your computations may produce garbage due to the lack
of precision attained using single precision.



More information about the Comp.lang.c mailing list