Re: Interesting behavior of double.NaN

"Brink, Paul ten" <[email protected]> Tue, 24 Mar 2009 09:43:20 +0100
Newsgroups gmane.comp.windows.devel.dotnet.advanced
Message-ID <D64DDB436E7D0F44AE255474D6320CCA6C9D941CBC@NLCLUEXM03.connect1.local>
> Hi,

>

> As you say, this is by design. Aside from this, however, you need to be careful testing floating point numbers for equality.

> http://docs.sun.com/source/806-3568/ncg_goldberg.html (reprint)

>

> John



Thanks, John, I was aware of this. But I am using this comparison in a property setter where you normally take some action if the new property value is not equal to the previous property value.



For doubles (and for floats for that matter) you have to be aware of this exception. Especially since in WPF (Silverlight) NaN can easily creep into your property value because FrameworkElements normally have a Width and Height property of double.NaN.



Cheers,

Paul


________________________________
The information contained in this message may be confidential and legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this message is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original message.

===================================
View archives and manage your subscription(s) at http://peach.ease.lsoft.com/archives