float.nan is not itself ?

2012-02-14 Thread Joshua Reusch
Hello, why does this assertion fail: assert(float.nan == float.nan); there is the std.math.isNaN function which works correctly, but why can I not just use the comparison ? Thanks, Joshua

Re: float.nan is not itself ?

2012-02-14 Thread Bernard Helyer
On Tuesday, 14 February 2012 at 15:39:37 UTC, Joshua Reusch wrote: Hello, why does this assertion fail: assert(float.nan == float.nan); there is the std.math.isNaN function which works correctly, but why can I not just use the comparison ? Thanks, Joshua Use `float.nan is float.nan`;

Re: float.nan is not itself ?

2012-02-14 Thread bearophile
Joshua Reusch: why does this assertion fail: assert(float.nan == float.nan); By design, the hardware that manages floating point numbers makes a NaN not equal to everything else, including other NaNs: http://en.wikipedia.org/wiki/NaN In D2 is performs a bitwise comparison, but keep in

Re: float.nan is not itself ?

2012-02-14 Thread Joshua Reusch
Thank you for the explanation ! bearophile wrote: Joshua Reusch: why does this assertion fail: assert(float.nan == float.nan); By design, the hardware that manages floating point numbers makes a NaN not equal to everything else, including other NaNs: http://en.wikipedia.org/wiki/NaN

Re: float.nan is not itself ?

2012-02-14 Thread Ali Çehreli
On 02/14/2012 07:48 AM, Bernard Helyer wrote: On Tuesday, 14 February 2012 at 15:39:37 UTC, Joshua Reusch wrote: Hello, why does this assertion fail: assert(float.nan == float.nan); there is the std.math.isNaN function which works correctly, but why can I not just use the comparison ?

Re: float.nan is not itself ?

2012-02-14 Thread Simen Kjærås
On Tue, 14 Feb 2012 16:39:37 +0100, Joshua Reusch yos...@arkandos.de wrote: Hello, why does this assertion fail: assert(float.nan == float.nan); there is the std.math.isNaN function which works correctly, but why can I not just use the comparison ? Thanks, Joshua My favorite

Re: float.nan is not itself ?

2012-02-14 Thread Stewart Gordon
On 14/02/2012 15:39, Joshua Reusch wrote: Hello, why does this assertion fail: assert(float.nan == float.nan); there is the std.math.isNaN function which works correctly, but why can I not just use the comparison ? A NaN typically denotes some kind of invalid computation. If the results

Re: float.nan is not itself ?

2012-02-14 Thread Manfred Nowak
Stewart Gordon wrote: If there were such a thing as bool.nan ... it would be called not-a-boolean. Of course it may make sense to compute something using such poisoned values. But if such values make sense, D is not prepared to use them, especially there is no if_then_else_otherwise