From: Paul Shirley Newsgroups: comp.os.msdos.djgpp Subject: Re: Fixed Point (Optimization) Date: Mon, 6 Jan 1997 03:02:52 +0000 Organization: wot? me? Lines: 32 Distribution: world Message-ID: References: <32cd6b2c DOT 4726585 AT nntp DOT southeast DOT net> <01b9bb84$bc3275a0$e2c5b7c7 AT platko DOT ix DOT netcom DOT com> <32cedb2d DOT 17212822 AT ursa DOT smsu DOT edu> Reply-To: Paul Shirley NNTP-Posting-Host: chocolat.foobar.co.uk Mime-Version: 1.0 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp In article <32cedb2d DOT 17212822 AT ursa DOT smsu DOT edu>, Tony O'Bryan writes >I did a quick check on floating point vs. integers not too long ago. >I wrote a small loop that only added an integer to an integer counter, >then rewrote it using floating point variables. On my Pentium 120, >integers were THOUSANDS of times faster. I don't remember the exact >numbers, but 50,000 loops required a few seconds with the floating >point. The integers were so fast that the timer (calculated to >several digits [7 or 8, I think]) couldn't register the elapsed time. First: floating point is slower at add and subtracts. If all you ever do is add/sub then integer will be 2* faster *at least*. If you use multiplies floating point is ~4-12* faster. Pipelined you get that 12* speedup. Divides are slightly faster in fpu but a lot less hassle than fixed point. If you use single precision fpu mode they are always 2* faster. Also its possible to continue issuing integer instructions while a float divide executes. That allows tricks like performing a perspective divide in effectively 1 clk. Second: in your test the compiler probably replaced you entire loop with a single load in the integer code. It could safely work out the final value! The float version had to actually do the calculations, its not allowed optimise away floating point calculations. Finally: The one thing to never do is mix integer and float operands. Float->int conversion are very slow, fpu integer operations are slow. --- Paul Shirley: shuffle chocolat before foobar for my real email address