• Advertisement
Sign in to follow this  

Performance of Double Vs Float

This topic is 4362 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a silly question to ask. Please, no making fun of the newbie. If floats and double both use the FPU stack, is there a difference in performance when doing math operations. Thanks for any replies.

Share this post


Link to post
Share on other sites
Advertisement
Depends, to a certain extent, on your architecture, I would imagine.

For example, PowerPC internally does fp operations w/doubles, even if your C code has floats. I don't know offhand what Intel does.

What might be more significant is memory bandwidth when you are dealing with a large number of them (say, for example, in vertex buffers). Copying a bunch of floats will be about half the work as copying the same number of doubles.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
As far as execution time, there shouldn't be a real difference between double and float... However, because double is bigger, I'd suspect that copying a double would take longer then it would a float.

I guess the easiest way to find out for sure is to profile some code...

Share this post


Link to post
Share on other sites
AFAIK, Intel FPU's do all calculations internally using long (80-bit) doubles. So there shouldn't be much (if any) performance difference besides potential cache effects caused by the size difference.

Share this post


Link to post
Share on other sites
Doubles take up twice as much space, so only half as many fit in the cache at the same time. That might have no impact in one application or make it run an order of magnitude slower in another application.

Share this post


Link to post
Share on other sites
The real issue that people have kind of mentioned but no one has hit is that doubles are twice as big, which means you can only move half as many of them in and out of memory. This can be a problem if you have a lot of data. And if you're doing a graphics application, GPU's use 32 bit floats anyway so using doubles is a waste.

Share this post


Link to post
Share on other sites
Moreover, sending doubles to the GPU in any way is going to impose a conversion in the driver which makes using doubles even slower.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement