Message-ID: <32D16662.76FE@pobox.oleane.com> Date: Mon, 06 Jan 1997 21:53:54 +0100 From: Francois Charton Organization: CCMSA MIME-Version: 1.0 To: Michael Phelps CC: djgpp AT delorie DOT com Subject: Re: FP vs int timings Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Michael Phelps wrote: > > b = (double)random(); > c = (double)random(); > a = b / c;[snip] > y = (int)random(); > z = (int)random(); > x = y / z;[resnip] > results on my 5x86/100 under Win95: > doubles: 2.29s for 1000000 divides > ints: 2.12s for 1000000 divides > > conclusions: on my machine, at least, there is not a significant > difference in speed between integer and floating-point math. (The If you want to compare their speed, you have to test fixed vs float on more than just a divide... As an example, fixed point math usually are good at addition and substraction, and I think the compares could also be quite fast. OTOH, fixed by fixed multiplies and divisions are slow (as you have noticed, in fact their are even worse than in your program, because there is one more shift involved)... But fixed by integer multiplies and divides are fast, and cast from int to fixed also are... and with fixed point numbers, you can index arrays... The list could go on. To me, on most modern machines (anything with a built in FPU basically), integer calculations are not significantly faster than floating point instructions *on the average*. However, if speed is a concern, they are worth experimenting with, they can help a lot at times... Francois