Advertisement

Fixed Point Math - Is It Worth It?

Started by July 13, 2001 01:05 PM
31 comments, last by LordElectro 23 years, 6 months ago
Flipping through my dog-eared copy of the original Tricks of the Game Programming Gurus (one of the most useful books I have ever bought) and looking through the optimization section in desperate attempts to make sure that the final archetecture I design for my 2D tile engine (and yes it''s a modern Windows app with DX and stuff) could incorporate possible significant speed increases, I came across the topic of fixed point math which I had forgotten about. Seems pretty easy to incorporate, and with C++, it can be made to work practically the same as any other numerical type. I also have some ideas on how to fix the accuracy problems mentioned with multiplication. However who on earth actually uses fixed point? I have never seen or heard it used or mentioned anywhere else. I can see it not being too practical for modern 3D, but speaking 2D, will implementing it result in significant benefits in a game where potentially there can be quite a few angle calculations and the like? I really want to implement these and look "l337" but if it''s going to cause more trouble than good in the long run, screw it. Resist Windows XP''s Invasive Production Activation Technology!
BetaShare - Run Your Beta Right!
Actually the lib Allegro uses fixed point to lots of things like rotating sprites. But I don''t find it as useful. Aren''t float point numbers better?

import money.*;
#include "cas.h"
uses bucks;
import money.*;#include "cas.h"uses bucks;
Advertisement
no, or not anymore, processors are built now for floatingpoint specific functions like games.

Reality Makes Me XIC
I don''t do spelling, I hack code: passion is my feul. Use my programs, experience genius.
http://www.x-i-c.com/
I am XiCI don't do talk, I code: passion is my feul. Use my programs, experience XiC. http://www.x-i-c.com/
quote:
Original post by JmarsKoder
no, or not anymore, processors are built now for floatingpoint specific functions like games.



But without having to use specific instruction sets yourself or not being compatible across by AMD and Intel?
BetaShare - Run Your Beta Right!

I use fixed point for my 2D game. For 3D games, use floating point all the way. But for 2D, I use fixed point for two reasons:

1. People who play 2D game maybe/probably have older machines, with slower FPU.

2. In 2D games, you will probably do a lot of operations that use integers only, like blitting, or keeping track of frame counters and whatnot. I''d rather stay away from doing float to int conversions, which are slow.

3. I like fixed point. I think it is cool.


Fixed point math was cool when Wolfenstein came out, because most x86 processors at the time had no support for floating-point calculations..

Does anyone remember math co-processors?..they don''t exist anymore because they are integrated into the cpu itself..

I''ve heard that Pentiums are optimized for floating point operations, and can do them faster than fixed point(at least that''s what I''ve heard)..





Advertisement
quote:
Original post by Anonymous Poster
I''ve heard that Pentiums are optimized for floating point operations, and can do them faster than fixed point(at least that''s what I''ve heard)..


See that is what i want to know. The book was published around 1994 though wasnt it? Yea, 1994. Co-processor was already extinct so it was still useful on 486s. But as Pentiums and up are concerned, I haven''t a clue about the effect of fixed point :/

My target audience has a Pentium at least, and the whole engine is meant to use today''s technology to deliver old skool stuff on today''s computers and maybe show that 2D isn''t necessairly bad.
BetaShare - Run Your Beta Right!
Yeah any of the 3D stuff is going to need floats anyway, so you might as well use ''em.
I can''t remember whether the best selling console in the world ever is the Gameboy or the Playstation. Either way neither of them have a floating point unit. Nor does the Gameboy Advance. Modern programmers don''t know about fixed point math. I''ve seen two adverts recently that advertised fixedpoint math as a requirement alongside assembler. If you do work with a PalmPC again you will be lacking an FPU. It''s not mandatory but knowing fixedmath will make you a more attractive proposition than a person without that knowledge.

People usually associated Assembler and Fixedpoint math with DOS, and if that is true, DOS is still alive and kicking...


Stay Lucky, Graham "Mournblade" Reeds,
ICQ: 30514803
http://homepage.dtn.ntl.com/grahamr/
Stay Lucky, Graham "Mournblade" Reeds,ICQ: 30514803http://homepage.dtn.ntl.com/grahamr/
quote:
Original post by Buster
Yeah any of the 3D stuff is going to need floats anyway, so you might as well use ''em.


There ... won''t ... be ... any ... 3D. At all. Not one x,y,z coordinate

So as long as fixed point math doesn''t end up hurting the engine (either by introducing that extra complexity or by actually being slower on modern comps) I would like to use it.

Trying to make the engine as stable and fast as I can. Been spending lots of time perfecting every detail.
BetaShare - Run Your Beta Right!

This topic is closed to new replies.

Advertisement