From: Endlisnis Newsgroups: comp.os.msdos.djgpp Subject: Re: Floating/fixed point Date: Sun, 20 Sep 1998 10:54:03 -0300 Organization: NBTel Internet Lines: 58 Message-ID: <360508FB.3610E852@unb.ca> References: <000201bde24f$5e1d1560$a14e08c3 AT arthur> NNTP-Posting-Host: fctnts10c63.nbnet.nb.ca Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Arthur wrote: > > I am using a Genuine Pentium 150 (Classic). And floating > > point operations > > take much longer than integer. I think it is about 5 times slower for > > floating point stuff. A floating point multiply takes about the > > same time as > > a floating point add, so if fadd's were as fast as add's then > > fmul's would be > > significantly faster than mul's. And everyone would use fmul's!! > I'll have to see your benchmark code to be convinced. Float-integer > conversion is very slow, as are if() statements. So no, people wouldn't use > fmul instead of mul. Here is the benchmark code. It revieled that my Pentium150 takes 3 clock cycles for 'fadd' while it only takes 1 cycles for 'add'. Therefore, regardless of how optimized your loop will be, fadd's will take at least 3 times longer than add's. #include #include //Code to check the Pentium cycle counter. float add(float a, float b) { float Ret; asm ("fadd %2, %0" : "=&t" (Ret) : "0" (a), "u" (b) ); return Ret; } float noadd(float a, float b) { float Ret; asm ("" : "=&t" (Ret) : "0" (a), "u" (b) ); return Ret; } int main() { float a=6, b=6; add(a,9.5); noadd(b,9.5); cout << NumCycles( for(int c=0; c<10000; c++) a=add(a,9.5); ) << endl; cout << NumCycles( for(int c=0; c<10000; c++) b=noadd(b,9.5); ); return 0; } -- (\/) Endlisnis (\/) s257m AT unb DOT ca Endlisnis AT GeoCities DOT com Endlis AT nbnet DOT nb DOT ca