Path: csiph.com!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: Walter Banks Newsgroups: comp.arch.embedded Subject: Re: Floating point vs fixed arithmetics (signed 64-bit) Date: Tue, 27 Mar 2012 13:56:49 -0500 Organization: Byte Craft Limited Lines: 63 Message-ID: <4F720D71.DFDA7F7F@bytecraft.com> References: Reply-To: walter@bytecraft.com NNTP-Posting-Host: p5D40tQM5Y+rh0hF1s2wxw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org X-Mailer: Mozilla 4.79 [en]C-CCK-MCD NSCPCD479 (Windows NT 5.0; U) X-Accept-Language: en X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.arch.embedded:7802 "David T. Ashley" wrote: > On Tue, 27 Mar 2012 18:52:09 +0300, upsidedown@downunder.com wrote: > > >On Tue, 27 Mar 2012 11:28:18 -0400, David T. Ashley > > wrote: > > > >> > >>Without FPU support, assuming that the processor has basic integer > >>multiplication instructions, integer operations are ALWAYS faster than > >>floating-point operations. Usually _far_ faster. And always more > >>precise. > > > >Floating point instructions MUL/DIV are trivial, just multiply/divide > >the mantissa and add/sub the exponent. > > > >With FP add/sub you have to denormalize one operand and then normalize > >the result, which can be quite time consuming, without sufficient HW > >support. > > > >This can be really time consuming, if the HW is designed by an idiot. > > Your observations are valid. But I have yet to see a practical > example of something that can be done faster and with equal accuracy > in floating point vs. using integer operations. > > I concur with your observations. After reading your first paragaph > ... yeah, floating-point multiplication is pretty simple so long as > the floating point format is sane. > > Before reading your post, I my mental model was that floating-point > operations might be 20 times as slow as integer operations. Now I'm > thinking maybe 2-3 times. I did a fixed point support package for our 8 bit embedded systems compilers and one interesting metric came out of the project. Given a number of bits in a number and similar error checking fixed or float took very similar amounts of execution time and code size in applications. For example 32 bit float and 32 bit fixed point. They are not exact but they are close. In the end much to my surprise the choice is dynamic range or resolution. There are other factors IEEE754 has potentially much more error checking but not all libraries a written to support it, and not applications need it. Regards, w.. -- Walter Banks Byte Craft Limited http://www.bytecraft.com