• Advertisement

Archived

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

Floating point vs. Interger

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Someone correct me if I'm wrong, but with today's processors (the pentium and up), floating point is no longer considered a problem of speed. So as for the difference between the two nowadays, who knows, because I'm not sure if anyone still uses fixed point, at least very often.

Kevin

Share this post


Link to post
Share on other sites
Advertisement
Since the Pentium, the floating point multiply instruction has actually been faster than the integer multiply instruction.

With today's hardware, there's very little need to do fixed point anymore. It's not worth the trouble.

I mean even if you could make a fixed point math library that was slighly faster than a floating point one, the extra code and development effort you'd spend getting around precision errors would cause a lot of pain and wasted time.

------------------
-vince


Share this post


Link to post
Share on other sites
if you plan to convert your floats to integers often, it might be worth using fixed point.

the only time i really used fixed point agressively was in a bitmap scaling routine (written in asm), where subpixel coordinates had to be converted to screen coordinates, which only required a bit shift. I don't think it would have been as fast using floating point numbers, and rounding them every pixel!

Share this post


Link to post
Share on other sites
About the only market left where using fixed point is an advantage is PSX development.
However, if you are thinking of doing conversions between types then definately be careful about how often and where you do them, they can account for a lot of processor speed.

Share this post


Link to post
Share on other sites
Floating point math is fast, integer math is fast. But converting from floating point to integer is slow. For those functions that convert from floating point to integer often use fixed point.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Floating point is now FASTER than integer math... plus the floating point operations can be done in parallel if coded right. Fixed point is dead.

Share this post


Link to post
Share on other sites
Fixed point is still very useful at times.

The pentium does have a separate FP module which makes floating point instructions execute in parallel. However, if you are going to be accessing the FP variables often your best bet is to use fixed point math.

There are certain situations for everything and there is no "right" answer all of the time. The trick is to time your code and test out your theories. Something that somebody tells you is useless may give you that extra speed-up you need.

For example, I have a floor/ceiling mapper in my current game. I converted it to Fixed point and I was rewarded with a frame rate increase of almost 3x. Yet, I -re-coded the rest of the enging to use fixed point and I didn't receive even a 1 FPS increase. The reason, I wasn't accesing the values often enough for it to matter.

If I would have never tried it out, then I would have missed out on that great speed improvement. It is your call. Personally, I never pay much attention to what people tell me will/won't work ...I tru for myself and see.

- Chris

Share this post


Link to post
Share on other sites
Yeah, a couple years ago I wrote a very simple raycasting engine in C using a 16-bit compiler. It was much faster using fixed-point math than floating-point, because the rays all had to be converted to fixed-point to find the screen coordinates.

It seem to me that rendering code is usually fastest as fixed-point, since screen coordinates always need to be integers, but the more high-level code can remain floating-point. Like what Chris said.

------------------
~CGameProgrammer( );

Share this post


Link to post
Share on other sites

  • Advertisement