Sign in to follow this  
fathom88

Performance of Double Vs Float

Recommended Posts

fathom88    180
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
mossmoss    326
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   
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
Sharlin    864
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
Trap    684
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
Puzzler183    540
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
oggialli    217
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this