Don't compare floats for equality

Robert Helling helling at atdotde.de
Wed Jan 22 00:04:04 UTC 2014


On 21.01.2014, at 23:10, Dirk Hohndel <dirk at hohndel.org> wrote:

> did you try to compile that patch?
> 
> FP_IS_SAME / IS_FP_SAME

ouch, you got me.

After a good night’s sleep, here is another small amendment: As we have abstracted the equality testing into a macro it doesn’t hurt anymore in terms of readability to do the right thing™ rather than the simple thing: Allowing for a relative error rather than an absolute (which would set an artificial scale). This basically says “we trust our data (which comes from the dive computer’s measurement after all) to a certain number of significant digits” rather than “we will never encounter anything smaller than 1 / a million but not zero” which would be awfully unit dependent.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Floating-point-equality-test-with-relative-rather-th.patch
Type: application/octet-stream
Size: 775 bytes
Desc: not available
URL: <http://lists.hohndel.org/pipermail/subsurface/attachments/20140122/f6ca0040/attachment-0001.obj>
-------------- next part --------------


Best
Robert
 
-- 
.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oO
Robert C. Helling     Elite Master Course Theoretical and Mathematical Physics
                      Scientific Coordinator
                      Ludwig Maximilians Universitaet Muenchen, Dept. Physik
                      Phone: +49 89 2180-4523  Theresienstr. 39, rm. B339
                      http://www.atdotde.de

Enhance your privacy, use cryptography! My PGP keys have fingerprints
A9D1 A01D 13A5 31FA 6515  BB44 0820 367C 36BC 0C1D    and
DCED 37B6 251C 7861 270D  5613 95C7 9D32 9A8D 9B8F




-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 495 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.hohndel.org/pipermail/subsurface/attachments/20140122/f6ca0040/attachment-0001.sig>


More information about the subsurface mailing list