Advertisement

quick math

Started by July 15, 2002 01:33 PM
1 comment, last by Lucidquiet 22 years, 2 months ago
Can somebody give me an idea as to how someone, like me, a newbie, might go about making certain math functions faster -- just an idea of how to do this. At first I was thinking using Assembly, but I wonderred if I was missing something. How quick can assembly really make certain math functions anyway? Thanks for your help, L-
"Education is when you read the fine print; experience is what you get when you don't." -Pete Seegerwww.lucid-edge.net
what are the math function you are trying to optimize? the functions in Math.h are already about as optimized as they are likely to get.

are you just looking to optimize your game code? if so, the bottle-necks are not likely to be math functions. game bottlenecks are usually in the way you draw polygons, are you using BSP trees to cut down on the number of objects sent to the card for render? are you doing as much drawing as possible with z-buffering turned off?

a good optimization is to minimize the number of divides that you do. if you have code like this:

poo = variable / x;
log = another / x;
dongle = yourmom / x;

it's better to do:

oneOverX = 1/x;

poo = variable * oneOverX;
log = another * oneOverX;
dongle = yourmom * oneOverX;

a good compiler should already optimize the math fctns for you, i doubt you'll gain much by going to assembler to fix things. the bigger gains will be got by restructuring your code.

-me

[edited by - Palidine on July 15, 2002 2:40:44 PM]
Advertisement
Well,

Assembler is the quickest. It''s kind of a tough language to master, though.

What kind of mathematics are you trying to improve the speed upon?
- Advice, eh? Well, besides working on your swing...you know, besides that...I'd have to think.

This topic is closed to new replies.

Advertisement