To: djgpp AT delorie DOT com Subject: Re: floating point is... fast??? Message-ID: <19970120.094829.4983.1.chambersb@juno.com> References: <5brd2e$dap AT lyra DOT csx DOT cam DOT ac DOT uk> <32E2D80E DOT 7760 AT gbrmpa DOT gov DOT au> From: chambersb AT juno DOT com (Benjamin D Chambers) Date: Mon, 20 Jan 1997 12:49:20 EST On Mon, 20 Jan 1997 10:27:26 +0800 Leath Muller writes: >> while using the profiler on some code i had written i noticed that >changing a >> floating point multiply to an unsigned multiply of 2 longs turned >out to be >> slower. in fact floating point multiply appears to be faster than >ordinary >> integer multiply for any case. is this actually true? and if so is >there any >> reason i shouldn't just change every multiply in my code to make >sure it's >> floating point? > >Yes, floating point is faster because imul and idiv use the floating >point unit to do the operations - thus an integer mul/divide has the >overhead of converting the int -> float, div/mul, then float -> int. >Whereas the floating point calculations just do the div/mul... > >Leathal. If this were true, I couldn't do ANY multiplication/division on my computer, since I have no FPU (I'm not counting Emulators here). The integer mul/div routines are so slow precisely *because* they do not use the FPU - they use the integer unit, which was not made for mul/div's. ...Chambers >