Archived

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

Poltras

Fixed Point vs Floating Point

Recommended Posts

Is it still useful to change your floating points variables into fixed point ones... I''m talking in speed. Back in time it was very useful but now with new FPU, is it still as fast as fixed point? Brievely: Is FLOATING POINTS nowadays with new FPUs are as fast as standard Integers or Fixed Points??? Thanks.
Programming is:
A.The art of debugging a blank sheet of paper (or an empty file).
B.A pastime similar to banging one's head against a wall, but with fewer opportunities for reward.
C.The most fun you can have with your clothes on (although clothes are not mandatory).

Share this post


Link to post
Share on other sites
It depends how you use them. You have to be much more creative and use inline assembler a lot if you want fixed point to be faster. But if you do it can be faster than floats. Especially if you can use MMX to its full potential. Of course on the other side if you used SSE or 3d now, you can do multiple float calculations at the same time.

Adding and subtracting fixed points is definitely faster. Multiplying a fixed point by a fixed point is a little slower / faster than floats depending on the CPU. Multiplying a fixed point by an integer is very fast, and division by an integer is fast enough.

The other thing is that once you use fixed point other optimizations become possible. For example because of how a multiplacation was being used in a loop I was able to turn it into 2 adds and an if. I would not have been able to the same optimization with floats.

For a good time hit Alt-F4! Go ahead try it, all the cool people are doing it.

Share this post


Link to post
Share on other sites
Now my own functions are crappy and I don''t know why... Would you please send me some examples of FixedDiv and FixedMul??? Thanks.

(( BTW, your answer is really appreciated ))

Share this post


Link to post
Share on other sites
I lost my code for both of those. Actually I'm not sure if I ever wrote one for divide.

I can tell you how I did my multiply. I used DWORD's for my fixed point values. I used the high 16 bits for the integer portion, and the low 16 for the decimal. I just used a mul r/m32. Then I shifted eax to the left 16 bits. I shifted the other register to the right 16 bits. Then I ored them.

If you still have trouble I can rewrite my original code.

For a good time hit Alt-F4! Go ahead try it, all the cool people are doing it.

Edited by - blue-lightning on June 19, 2000 11:28:25 PM

Share this post


Link to post
Share on other sites
Even if it was possible to do that typedef, consider the implications of missing that include only ONCE in your code. It won''t complain, because float is a predefined type - but you will get REALLY nasty bugs that are near to impossible to find.

I don''t think it will let you do that, in other words


Give me one more medicated peaceful moment..
~ (V)^|) |<é!t|-| ~

Share this post


Link to post
Share on other sites
I think some explanation is require here.

Floating-point is faster than FIXED & INT. (On news CPU - Pentium)

When you use fixed-point you create a STALL in your CPU Pipe-Line, while using Floting-Point you can do a mult/div, and after you can put 2 adds (a precision dont use the answer from fmul/fdiv as operants of following OPs).

It''s work that way, ''cause on Pentium CPU you have a unique Pipeline for Floting-Point number. And this is more true on new RISC processor.

So dont be afraid of using Floating-Point number, they will become faster and faster then FIXED and INTS, just ''cause how the floating-point is BUILD.

To get more information on that, Chech Intel''s WebSite. Check on pentium OPTIMIZATION, this will amaze you !!!

LowRad

Share this post


Link to post
Share on other sites
I concur with LowRad

Due to pipelining and super-scaling capibilities of modern processors, float-point math has greater through-put than integer math.

The first integer math op will complete first, the second or third may too, but then the fp pipeline catches up & passes it because it''s calculating more per clock tick, but at a latency delay.

Specific numbers are processor & instruction set dependant.

And if you''re going to use HW acceleration, you may have to convert those int''s to fp''s anyway

Share this post


Link to post
Share on other sites