float / double support in Python?

Erik Max Francis max at alcyone.com
Fri Feb 7 10:12:37 CET 2003


Brandon Van Every wrote:

> I hope to - rather I have - introduced a statement of fact about a
> particular problem domain.  For instance, DirectX Graphics only takes
> 4-byte
> floats.  I have no interest in using 8-byte doubles for my game code. 
> Aside
> from API compatibility issues, it's piggish in terms of both space and
> time.

The irony of all this is that most modern FPUs do computations with the
full-width floating point types (C doubles instead of C floats), so
sometimes doing arithmetic in C floats rather than C doubles is
counterintuitively _more_ expensive than doing them in doubles directly,
since all the usage of floats gains you is the overhead of conversions.

3D APIs tend to offer C float interfaces (good ones like OpenGL offer
both) usually only to save on bus traffic.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ I'll be your strength / I'll be here when you wake up (all right)
\__/ Sweetbox
    7 Sisters Productions / http://www.7sisters.com/
 Web design for the future.




More information about the Python-list mailing list