From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,37e5589e32d8f03f X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Floating-Point Numbers and Internal Representation Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: Date: Sun, 4 Dec 2005 12:46:19 +0100 Message-ID: NNTP-Posting-Date: 04 Dec 2005 12:46:18 MET NNTP-Posting-Host: bc62ec1d.newsread4.arcor-online.net X-Trace: DXC=_CV6RS58?JUW4R5Sih0g1S:ejgIfPPldTjW\KbG]kaMXFYk:AnJB[C]C17_l3Fi;HU[6LHn;2LCV^[ On Sun, 4 Dec 2005 11:33:32 +0100, Matthias Kretschmer wrote: > I had a problem in one of my programs, that was caused by the internal > representation of floating-point numbers in the fpu. Concrete: > calculating the value of an optimum for some large number of objects, > then in a second doing something with all optimal objects. The problem > was, that when doing the calculation the second time, the compiler left > the floating-point number in the fpu which had a higher precision than > the representation I choosed, so comparing for equality returns always > "False". Why would you like to compare FP values for equality? It should be abs (X - Y) < Eps where Eps is known from the algorithm you are using. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de