This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [offtopic] float vs. double?


 
>> Has anyone done any benchmarks of float vs. double performance on
>> Pentium II?  Is there anything much to be saved by using float over
>> double?

>Although I haven't done any benchmarks, the general literature says that
>using double is faster on modern CPU's.  The reason is that the hardware
>does double precision calculations anyway.  This means that floats will
>be converted to double, the calculation performed, and, finally, the
>answer will be converted back to float (assuming no optimizations).

This sounds plausible.  But note that one can also reason heuristically
as follows:  for a small group of numbers, the difference in speed between
using float and double, in otherwise identical programs, is likely
to be insignificant, and double precision gives more numerical stability.
For very large vectors and matrices of numbers, the speed differences due to
memory usage and the amount of data that needs to be copied around
is likely to be much greater than the differences between the speed
of the computations themselves, so float could sometimes give a real
advantage.  It would be nice to know at what "very large" means on
any given machine - this would need to be deterimined experimentally.


- Josh

jstern@citilink.com




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]