Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.arch.embedded > #20092
| From | glen herrmannsfeldt <gah@ugcs.caltech.edu> |
|---|---|
| Newsgroups | comp.arch.embedded |
| Subject | Re: two fpu compared |
| Date | 2015-02-15 14:33 +0000 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <mbqaol$ab4$1@speranza.aioe.org> (permalink) |
| References | <ck36l8Fak5nU1@mid.individual.net> <mbht2f$v21$1@dont-email.me> <ck6f5eF66ovU1@mid.individual.net> <mbnpm6$m03$1@speranza.aioe.org> <mboe3j$io$1@dont-email.me> |
Dimiter_Popoff <dp@tgi-sci.com> wrote: (snip on validating floating point calculations, where someone wrote) >>>>> assuming two differently implemented FPU, both validated against the >>>>> IEEE754, and limiting operations to the golden 5 (+,-, *, /, sqr), can I >>>>> be sure that provided the inputs operands are the same the result would >>>>> be the same bit wise? (snip, then I wrote) >> Are you sure the calculation should be done in floating point? >> Without more details, I suspect it could be done in fixed point, >> the results would not vary depending on implementations, and >> everyone would be happy. > Sometimes the choice to do something using an FPU is not because things > cannot be done using the integer unit but just because one needs the > horsepowers the FPU adds to the chip. Was the case with me on my > netMCA-3 design - the FPU did make things a bit more complicated but > using it was the only way to do what I did. Apart from the sheer > ops per clock cycle it (being 64 bit of course, 32 bit FPU-s are > pretty much useless) gave me the dynamic range I needed (32 bits > integers would not have sufficed and multiprecision would have > slowed things down beyond any practical usability). 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. But there are calculations where the required uncertainty does not scale with the size of the problem. I expect a bank to keep my balance to the cent, if I have one dollar or billions of dollars in my account. (Well, I won't have billions of dollars, but a big corporation might.) Note also that for such quantities the values never get really small or really big. There is no use in computing with picodollars or exadollars. The US IRS allows rounding to the nearest dollar, there there are a few cases where ratios are computed to a specified number of decimal places. These calculations are best done in fixed point. Because of the demand from scientists, many computers do have faster floating point processors than fixed point, but often enough the difference isn't all that large. Within a reasonable range one can get exact results from floating point add, subtract, and multiply. You have to be a lot more careful with divide. With approriate values, add, subtract, and multiply will never round off the result, but divide can always do that. >> (There is only one question left, and that is the way division >> works when one operand is negative.) > Why is that, what pitfalls do you envisage? "Normally" one would > divide the absolute values and just xor the sign bits after that, > you must have something else/more to it than that in mind. That is the usual way, at least partly for historical reasons. It is usual for fixed point divide to return a quotient and remainder. (Floating point pretty much never returns a remainder.) In the case of a negative divisor, there are cases where one still wants a positive remainder. Consider the simple case where one is keeping track of a date and time, with some epoch (time origin). It simplifies many calculations, if you keep the time positive even when the date goes negative. If it is now 06:22 on the 15th day, 30 days ago, the clock will have read 06:22 on the -15th day, and not -13:38 on the -14th day. (No matter what the day, a clock never reads a negative time.) There are a fair number of problems in mathematics where one wants a modulo (remainder) operations with this property. The early binary computers used sign magnitude representation, where the XOR of the two signs is applied to the quotient and remainder. That isn't so obvious for twos complement, but is commonly done. Traditionally C allowed for either quotient and remainder in the case of a negative divisor, as long as the two were consistent. (That is, the / and % operators had to give appropriate results.) Fortran, which originated on sign magnitude machines, requires the remainder sign to match the divisor sign. (I believe C has changed to require this, too.) When Fortran required one, and C allowed both, it was obvious to hardware designers which way to go. Many mathematicians would disagree. (It is mostly in discrete mathematics where one wants an unsigned modulo.) -- glen
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