Re: Really strange problem, for very bright people
"George J Belland" <[email protected]> Fri, 08 Aug 2003 22:23:16 -0500
| Newsgroups | gmane.comp.lang.delphi.programming |
|---|---|
| Organization | geodentech.com |
| Message-ID | <3F3422D4.3386.7C58230@localhost> |
The reason is probably the rounding errors incurred during processing differ when the order of the values changes. Put the following formulas into a spreadsheet and see the differences ROUND(1.5 * 3) * ROUND(2.5*4) = 50 ROUND(1.5 * 4) * ROUND(2.5*3) = 48 Formulas are processed in chunks, so x = a * b * c * d will probably be processed something like this: x = a * b x = x * c x = x * d On 8 Aug 2003 at 20:09, Daniel Rail wrote: > Hi, > > At August 8, 2003, 16:57, Stephen Wood wrote: > > > I understand that clearly, but what I'm failing to understand is how the > > following occurs... > > > 1.035 * 4.32765 * 1.673 > > > gives different answers to > > > 1.673 * 1.035 * 4.32765 and 4.32765 * 1.673 * 1.035 > > > They are the same numbers, just in a different sequence.... > > > (Please note, these are not the numbers in my original equation, I've just > > written some very simplified numbers to illustrate the problem) > > > The only thing I can think of, is that the order of the calculation, and > > therefore the order of precision loss, has a different outcome on the final > > answer.... > > > Very strange... > > It is strange, but you have to accept it as a fact-of-life for as long > as it is the standard for the CPU's FPU(Floating-Point Unit). > > Look at your equations as follows: > (1.035 * 4.32765) * 1.673 > (1.673 * 1.035) * 4.32765 > (4.32765 * 1.673) * 1.035 > > The values are considered as floating-point values, especially if the > resulting value is a floating-point. What it sent to the CPU's > floating-point processor, is only the multiplication of 2 numbers, not > the whole equation. So, basically, the first 2 numbers get multiplied, > then that result(which has been approximated by the CPU) is multiplied > by the 3rd number. And, that result is also approximated by the CPU. > And, not to forget that the separate numbers are also approximated, > since they are considered to be floating-point values. > > -- > Best regards, > Daniel Rail > Senior System Engineer > ACCRA Group Inc. (www.accra.ca) > ACCRA Med Software Inc. (www.filopto.com) > > > > CodeCoffer - new Delphi code protection Tool! > http://www.delphicollection.com/public/CodeCoffer.htm > --------------------------------------------------------------- > Unsubscribe:[email protected] > List owner:[email protected] > --------------------------------------------------------------- > > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ > > > *************************************************************** You can enter a weekly drawing to win a dozen roses free at: www.flowerniche.com/index.html#winroses *************************************************************** Visit Our WebSite at www.geodentech.com ********************************************************* This email and files transmitted may contain privileged information. Any unauthorized disclosure, use or dissemination, either whole or partial, is prohibited. If you receive this message in error please return it to the sender and delete all copies. Thank you ------------------------ Yahoo! Groups Sponsor ---------------------~--> Buy Ink Cartridges or Refill Kits for Your HP, Epson, Canon or Lexmark Printer at Myinks.com. Free s/h on orders $50 or more to the US & Canada. http://www.c1tracking.com/l.asp?cid=5511 http://us.click.yahoo.com/l.m7sD/LIdGAA/qnsNAA/i7folB/TM ---------------------------------------------------------------------~-> CodeCoffer - new Delphi code protection Tool! http://www.delphicollection.com/public/CodeCoffer.htm --------------------------------------------------------------- Unsubscribe:[email protected] List owner:[email protected] --------------------------------------------------------------- Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/