Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.arch.embedded > #20119
| From | Dimiter_Popoff <dp@tgi-sci.com> |
|---|---|
| Newsgroups | comp.arch.embedded |
| Subject | Re: two fpu compared |
| Date | 2015-02-18 17:54 +0200 |
| Organization | TGI |
| Message-ID | <mc2ci7$2ig$1@dont-email.me> (permalink) |
| References | (3 earlier) <mbnpm6$m03$1@speranza.aioe.org> <mboe3j$io$1@dont-email.me> <mbqaol$ab4$1@speranza.aioe.org> <mc02kt$1i0$1@dont-email.me> <mc0rdr$11k$1@speranza.aioe.org> |
On 18.2.2015 г. 03:55, glen herrmannsfeldt wrote: > Dimiter_Popoff <dp@tgi-sci.com> wrote: > > (snip, I wrote) > >>> Many science and engineering problems have a large dynamic >>> range, and require results with a relative error (uncertainty). > >>> Lengths can be from nanometers to gigameter, times from picoseconds >>> to gigayears, and masses from eV to the mass of large stars. >>> One can measure the atomic spacing in a crystal lattice or the >>> distance between planets with a relative uncertainty of about >>> one part in a million. Floating point is great for this. > >> Yes, this is the primary purpose of FP. I just gave an example how >> it can be practical to use an FPU for some other reason, not the >> primary one (i.e. one can make use of the horsepowers it provides >> in parallel to the integer unit even though the calculations can >> be done quite well in integers (the first time I implemented that >> same conversion algorithm of mine was on a TI 5420 DSP, >> using integers). > > Yes, but you want to be sure that it gives the right answer. Well of course. But then arithmetic is not such a high science, you know. All you have to do is do the respective homework :-). > >>> There are a fair number of problems in mathematics where one >>> wants a modulo (remainder) operations with this property. > >> I did not realize you were talking integer divide, I though you >> were referring to FP division hence me being puzzled. FP (IEEE FP >> at least) maintains the mantissa as an absolute value and the sign >> is not a part of it, then there is no remainder etc :-). > > If a problem is defined in fixed point, and you want to do it > in floating point instead, you want to be sure it will give the > right result. Floating point rounding can give a different result > than integer divide would, after converting the result to integer. Hmmmm, not really. As long as there is no precision lost during normalization/denormalization the result should be the same, rounded to the nearest (or whatever the rounding mode has been set to, if settable). Integer divide would round to the smaller value if it returns quotient and remainder, it is up to the programmer to resolve the remainder and round to the nearest (I usually do it this way unless there are other considerations). > The discussion on remainder has to do with the way integer divide > works. > > It should always be true that (a/b)*b+a%b==b (C notation). > That is, divide and modulo (remainder) have to be consistent, > though in the case of negative operands there are two possible > choices. Yes, I have lost the count of divides I have written for various processors over the years, there is nothing special about it. > But even with both positive, floating point can round in an > unexpected way. Ouch, no. Different yes, unexpected - no, one has to know how the FPU behaves, otherwise it is just broken. > > Assuming you avoid the problems of negative division, fixed point > should always give the same result, but floating point might not. Hmmm, I can't think of a way the FPU would yield two different results for the same calculation without its controls being altered. Especially if the operation is doable using integer division, this would mean no mantissa bits will be lost during normalization/denormalization (assuming 32 bit integer divide, obviously one can write integer divide for a longer word than the typical 53 bits on FP). Dimiter ------------------------------------------------------ Dimiter Popoff, TGI http://www.tgi-sci.com ------------------------------------------------------ http://www.flickr.com/photos/didi_tgi/
Back to comp.arch.embedded | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
two fpu compared al.basili@gmail.com (alb) - 2015-02-12 08:30 +0000
Re: two fpu compared David Brown <david.brown@hesbynett.no> - 2015-02-12 10:51 +0100
Re: two fpu compared al.basili@gmail.com (alb) - 2015-02-13 14:14 +0000
Re: two fpu compared David Brown <david.brown@hesbynett.no> - 2015-02-13 16:23 +0100
Re: two fpu compared Colin Paul de Gloucester <not_a_real_email@address.com> - 2015-02-13 17:37 +0100
Re: two fpu compared al.basili@gmail.com (alb) - 2015-02-16 08:01 +0000
Re: two fpu compared Colin Paul de Gloucester <not_a_real_email@address.com> - 2015-02-16 11:43 +0100
Re: two fpu compared al.basili@gmail.com (alb) - 2015-02-17 10:35 +0000
Re: two fpu compared David Brown <david.brown@hesbynett.no> - 2015-02-17 12:18 +0100
Re: two fpu compared George Neuner <gneuner2@comcast.net> - 2015-02-17 09:26 -0500
Re: two fpu compared David Brown <david.brown@hesbynett.no> - 2015-02-17 16:47 +0100
Re: two fpu compared Dimiter_Popoff <dp@tgi-sci.com> - 2015-02-17 20:54 +0200
Re: two fpu compared al.basili@gmail.com (alb) - 2015-02-16 07:58 +0000
Re: two fpu compared David Brown <david.brown@hesbynett.no> - 2015-02-16 09:53 +0100
Re: two fpu compared al.basili@gmail.com (alb) - 2015-02-16 09:47 +0000
Re: two fpu compared Richard Damon <Richard@Damon-Family.org> - 2015-02-16 08:27 -0500
Re: two fpu compared Nobody <nobody@nowhere.invalid> - 2015-02-23 00:13 +0000
Re: two fpu compared George Neuner <gneuner2@comcast.net> - 2015-02-13 18:43 -0500
Re: two fpu compared glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-02-14 15:30 +0000
Re: two fpu compared Dimiter_Popoff <dp@tgi-sci.com> - 2015-02-14 23:19 +0200
Re: two fpu compared Hans-Bernhard Bröker <HBBroeker@t-online.de> - 2015-02-14 23:28 +0100
Re: two fpu compared glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-02-15 14:33 +0000
Re: two fpu compared Dimiter_Popoff <dp@tgi-sci.com> - 2015-02-17 20:53 +0200
Re: two fpu compared glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-02-18 01:55 +0000
Re: two fpu compared Dimiter_Popoff <dp@tgi-sci.com> - 2015-02-18 17:54 +0200
Re: two fpu compared glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-02-18 16:52 +0000
Re: two fpu compared Hans-Bernhard Bröker <HBBroeker@t-online.de> - 2015-02-18 18:12 +0100
Re: two fpu compared Robert Wessel <robertwessel2@yahoo.com> - 2015-02-18 18:02 -0600
Re: two fpu compared Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2015-02-19 09:42 +0200
Re: two fpu compared Robert Wessel <robertwessel2@yahoo.com> - 2015-02-19 11:04 -0600
Re: two fpu compared Reinhardt Behm <rbehm@hushmail.com> - 2015-02-19 23:26 +0800
Re: two fpu compared Dimiter_Popoff <dp@tgi-sci.com> - 2015-02-18 19:18 +0200
Re: two fpu compared Dimiter_Popoff <dp@tgi-sci.com> - 2015-02-19 02:28 +0200
Re: two fpu compared glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-02-19 16:29 +0000
Re: two fpu compared Dimiter_Popoff <dp@tgi-sci.com> - 2015-02-21 16:07 +0200
Re: two fpu compared glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-02-12 11:26 +0000
Re: two fpu compared "Boudewijn Dijkstra" <sp4mtr4p.boudewijn@indes.com> - 2015-02-12 12:29 +0100
Re: two fpu compared Dennis <dennis@none.none> - 2015-02-12 09:45 -0600
csiph-web