**From:** Hoelz, Thomas (*Thomas.Hoelz_at_gedas.de*)

**Date:** Wed Mar 07 2001 - 09:02:28 GMT

**Next message:**Russell Browne: "Re: Different printed output with floating point numbers"**Previous message:**Hoelz, Thomas: "Floating point numbers"**Messages sorted by:**[ date ] [ thread ] [ subject ] [ author ] [ attachment ]

Hello, sorry for the typo in my previous mail. Of course it's necessary to compute a difference before comparing against an epsilon. Thomas Hello Bob, in my opinion your experience results from the limited precision a computer uses to represent floating point numbers. In contrast to integers, floating point numbers on a computer are never exact representations of their mathematical counterparts! It's a well known problem in using floats that a comparison of two floats might yield differing results, even if the computation should result in equality in a mathematical sense. Example: float a, b; a = 20; b = 5; if ( a / b == 4 ) printf("Equality"); // may fail float c = a / b; if ( c - 4 < 0.0000001 ) printf("Equality"); // uses a so called "epsilon" to decide on // equality of two floats Greetings Thomas

**Next message:**Russell Browne: "Re: Different printed output with floating point numbers"**Previous message:**Hoelz, Thomas: "Floating point numbers"**Messages sorted by:**[ date ] [ thread ] [ subject ] [ author ] [ attachment ]

*
This archive was generated by hypermail 2.1.4
: Wed Feb 13 2002 - 21:51:33 GMT
*