On 12 Jul 2005 05:14:04 -0400, "Michael Tiomkin" <[EMAIL PROTECTED]> wrote:
> There is an old rule: never assume or check equality of two floating >point numbers. I know about that rule, but I think it's a bad one. In our company's code, numerical problems are unavoidable and occur from time to time. Some colleagues introduce tolerances whereever doubles are compared. Eventually they have numerical problems in spite of the tolerance, modify the tollerance to fix it - and get another numerical problem some time later. My opinion is that it is better to introduce tolrances only in cases where it is absolutely unavoidable. The example discussed here is not among these. Keep rounding errors in the mind (e.g. do not write if (a<=b*c) break; but do not introduce numerical problems by using tolerances in cases where there are no initial numerical problems. The solution with long double works fine. The original code has been working fine for years on other operating systems. Thank you to everybody who posted a reply. Greetings, Onno [I agree. I know there's a meme of "all floating results are wrong" but it's not true. -John] _______________________________________________ Help-gplusplus mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-gplusplus
