#### Archived

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

# Fixed-Point Math

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

## Recommended Posts

Hi, I was curious to know if fixed-point math is still worthwile? tj963

##### Share on other sites
If you''re programming for: PlayStation 1, GameBoy and any other handheld console (GBA etc), mobile phones etc then yes it''s worthwhile.

If you''re programming for: PS2, GameCube, Xbox, PC etc, then no it''s not really that worthwhile since modern CPUs have hardware floating point units which are extremely quick (i.e. you could do an FPU add in fewer cycles than the integer shift and add).

The only place the old-school techniques can sometimes still be quicker is for combinations of complex operations which take hundreds of cycles [for example a square root with a cosine]. Not always, and not as simple as many naive people would have you believe - profile old-school methods on modern CPUs, running under current OSes - don''t rely on profiles from 1994!

--
Simon O''''Connor
Creative Asylum Ltd
www.creative-asylum.com

##### Share on other sites
quote:
Original post by S1CA
If you''re programming for: PS2, GameCube, Xbox, PC etc, then no it''s not really that worthwhile since modern CPUs have hardware floating point units which are extremely quick (i.e. you could do an FPU add in fewer cycles than the integer shift and add).

At least for the PS2, while you''ll do most everything with floating point, it''s still worth understanding fixed point, as your nice floating point values will be converted to fixed point values of various widths. Yes, the graphics synth on the PS2 is still mostly 2D.

---- --- -- -

##### Share on other sites
yep. Knoweledge of fixed point is still useful. But I thought the originial poster was talking about using it as an alternative to floating point code.

And yep, I know about the GS (got the black DTL-P1102x manuals on my desk right now...) - mipmapping & perspective correction - mmmm do your own Q''s mmm nice ;-). Personally prefer NGC for clenliness and ease of coding....

##### Share on other sites
Slightly off topic, but could someone please explain why floating point is now the standard data type?

To me, it doesn''t seem logical because even with its large range, for games (and I assume other applications), once you get to those higher values, the prescision is lost, so you could even get to a point where adding 1 to the number will not change it (and I realise that the number 1 isn''t some special number too ). So for many purposes, the range is also limited by a lot.

Using fixed point, the prescision will be constant throughout the entire range, thus you can do the same stuff everywhere.

I''m not sure about performance. While floating point is probably about the same as fixed point now in terms of performance, my logic says that it should be possible to make fixed point faster than floating point.

Trying is the first step towards failure.

##### Share on other sites
ragonastick: depends.
While developing for the GBA, fixed-point is not just an option -it''s the only way, since the ARM7TDMI cpu doesn''t feature a floating point unit.

On the other hand fixed-point (at least in terms of multiplication and addition/subtraction) is not faster than floats on modern 32 bit CPUs because the speed you gain with using integer math is lost by the add and shift operations you have to perform.

You probably would make it faster than float on systems with weak floating point units, but look at all these 3DNOW!,SSE and SSE2 extensions - the trend is definitely going floating point math. As for the precision, they''re superior to fixed point
due to the fact that you can use 64 bit and even 128 bit floats
while you still have to deal with a 32 bit architecture on the integer side (you sure could use two 32 bit ints for representing a fixed point number but that would still be no match for a 64 bit float when handling numbers in the range 0..1)

1. 1
Rutin
26
2. 2
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 22
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631763
• Total Posts
3002191
×