Archived

This topic is now archived and is closed to further replies.

jonbell

Float or Double

Recommended Posts

The obvious:

double
- Higher precision

float
- Faster (not always)
- Less memory

For graphics, precision doesn''t matter all that much, which is why floats are often used.

Cédric

Share this post


Link to post
Share on other sites
The FPU should handle floats and doubles at the same speed. It''s the extra size (read: memory bandwidth used) that causes the difference. When using SIMD instructions, twice as many floats can be processed as doubles.

I agree with Cedric... you most likely won''t need the added precision. Try it out. If you get precision problems, you can always switch to doubles. I''d recommend a simple:

  
typedef float real_t;


Use real_t everywhere. If you find the need to use extra precision, all you need to do is change the typedef.

Share this post


Link to post
Share on other sites
How does double multiplication not take more cycles than float multiplication if they are same speed?

Share this post


Link to post
Share on other sites
AFAIK, the FPU converts from 32bit (or 64bit) to a standard precision (80bit on Intel processors, 64bit on some, though not all, AMD processors) and converts back upon storing. The multiplication is done entirely using those registers, taking 3 clock ticks. Funnily, depending on the state of the floating point control word, division does take a different number of ticks for each precision (19 ticks for 24bit precision, 33 ticks for 53bit precision, 39 ticks for 64bit precision)

These timings are for Pentium/Pentium MMX. The situation is analogous (if a little more complicated) for more recent processors.



[edited by - Kippesoep on November 6, 2002 11:06:52 AM]

Share this post


Link to post
Share on other sites