#### Archived

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

# Float or Double

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

## Recommended Posts

What are the pro''s and con''s of using floats or doubles in 3D gfx? Which should i use?

##### Share on other sites
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 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 on other sites
How does double multiplication not take more cycles than float multiplication if they are same speed?

##### 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]

• ### Forum Statistics

• Total Topics
628701
• Total Posts
2984290

• 22
• 10
• 9
• 13
• 13