المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Equality of floating point numbers



C# Programming
06-21-2009, 09:40 PM
Okay, I think that I understand the issues affecting C# equality testing (including numerical precision, type conversions, boxing etc) - e.g. http://blogs.msdn.com/jmstall/archive/2005/03/09/390135.aspx[^ (http://blogs.msdn.com/jmstall/archive/2005/03/09/390135.aspx)] - but I don't understand the statement in MSDN (http://msdn.microsoft.com/en-gb/library/bsc2ak47.aspx[^ (http://msdn.microsoft.com/en-gb/library/bsc2ak47.aspx)]):

x.Equals(x) returns true, except in cases that involve floating-point types. See IEC 60559:1989, Binary Floating-point Arithmetic for Microprocessor Systems.
Can anyone please explain? How can this sometimes evaluate to false?
(I couldn't find anything interesting re: IEC 60559:1989 - still Googling though.)

P.S.
double d = Double.NaN;
d.Equals(d); // is still true - although it doesn't have to be under the standard

"...there's what people want to hear, there's what people want to believe, there's everything else, THEN there's the truth!" - New York D.A., The International