🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Fixed-Point math

Started by
4 comments, last by Jallen 24 years, 1 month ago
Has anyone ever used fixed-point math in any projects they do? What I would like to know is with todays fast CPUs with multiplely pipelinged floating point units, etc.. is there a noticable gain in speed (above 20% gain) when using strictly integer based mathematics? Jason A. --- I write code.
---I write code.DelphiGL (http://delphigl.cfxweb.net)
Advertisement
If you are writing your own personal software renderer there can still be noticable gains in speed. (If you do it right.) However, if you try to use any 3d APIs (OpenGL, Direct3D) you need to convert the fixed point values to floating point values and that conversion takes long enough that everything you gained will be lost.
Well... Floting point math and integer based math (used for fixed point) are about the same these days, so whichever you choose will be about the same (unless you use OpenGL or something, then use floats, as SiCrane mentioned)

Morgan
Floats are actually faster nowadays.

Theres a small table of comparisons at http://www.d6.com/users/checker/pdfs/gdmfp.pdf

The reason that a software renderer can be slightly faster with ints rather than floats is that at some point in the drawing pipeline the output must be converted to ints...this is a quite slow step and hogs the processor.

With OpenGL and D3D which use floating point maths internally, I would have thought that using int would slow it down slightly as they would have to be converted before being used.

dan
Float and doubles are very good for math. If you''re doing some vector/matrix calculation - best to use FPU.
(Div Mul Sqrt Sin Cos)

On the other hand, if you''re doing some blitting or writting a fast inner loop with simple math (add,sub) - best to use fixed point.
(Add Sub Shift)

Maybe if compilers will make optimal use of MMX, this will change the situation! Add, Sub, Shift and Mul are much much faster with MMX.
(Add Sub Shift Mul)

In other words:
I''m only using fixed point for my software rendered polygon drawing proc.
If you''re using OpenGL/Direct3D - stick to floats!

This topic is closed to new replies.

Advertisement