From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Floating-Point Numbers and Internal Representation
Date: Sun, 4 Dec 2005 12:46:19 +0100
Date: 2005-12-04T12:46:18+01:00 [thread overview]
Message-ID: <ne1755n7foit.1wvcxg3ez9032.dlg@40tude.net> (raw)
In-Reply-To: slrndp5hlm.k99.mccratch@thrakhath.kilrathi.lcn
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
next prev parent reply other threads:[~2005-12-04 11:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-12-04 10:33 Floating-Point Numbers and Internal Representation Matthias Kretschmer
2005-12-04 11:12 ` Martin Krischik
2005-12-04 14:11 ` Martin Dowie
2005-12-04 14:50 ` Dmitry A. Kazakov
2005-12-04 15:15 ` Matthias Kretschmer
2005-12-04 18:14 ` Dmitry A. Kazakov
2005-12-04 21:16 ` Matthias Kretschmer
2005-12-06 2:54 ` Steve
2005-12-05 23:38 ` Randy Brukardt
2005-12-04 11:46 ` Dmitry A. Kazakov [this message]
2005-12-04 21:29 ` Gautier Write-only
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox