Re: Really strange problem, for very bright people
Daniel Rail <[email protected]> Fri, 8 Aug 2003 20:09:11 -0300
| Newsgroups | gmane.comp.lang.delphi.programming |
|---|---|
| Message-ID | <[email protected]> |
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) ------------------------ Yahoo! Groups Sponsor ---------------------~--> Low on Ink? Get 80% off inkjet cartridges & Free Shipping at 77Colors.com. We have your brand: HP, Epson, Lexmark, Canon, Compaq and more! http://www.c1tracking.com/l.asp?cid=5981 http://us.click.yahoo.com/DmnqpB/IyhGAA/ySSFAA/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/