IsNaN

  • Thread starter Thread starter Pertti Martikainen
  • Start date Start date
P

Pertti Martikainen

Hi,

The following lines are from my Immediate - window:

dValue
NaN
Double.IsNaN(dValue)
false

I evaluate variable dValue, I get NaN but IsNaN returns
false. What am I doing wrong?


Best Regards
Pertti
 
Not sure - do you have a reproducible test case?

Yes i do. I think that it has got something to do with way
I get the value into dValue variable - see following
Immediate-window lines:

Double.IsNaN(1.0 / 0)
true
Double.IsNaN(1.0 / 0.0)
true
Double.IsNaN(1 / 0.0)
false

I have allready got a workaround.
 
Pertti Martikainen said:
Yes i do. I think that it has got something to do with way
I get the value into dValue variable - see following
Immediate-window lines:

Double.IsNaN(1.0 / 0)
true
Double.IsNaN(1.0 / 0.0)
true
Double.IsNaN(1 / 0.0)
false

None of these should show true - they should all be positive infinity,
which isn't a NaN.

(Out of interest, what happens if you test for
Double.IsPositiveInfinity for each of the above?)
I have allready got a workaround.

In my experience, the usual workaround is to avoid using the debugger
for this kind of thing. Lots of people have seen problems (which may
now have been fixed) with either the immediate window or the watch
window for strings - this sounds like a similar kind of thing.
 
(Out of interest, what happens if you test for
Double.IsPositiveInfinity for each of the above?)

Double.IsPositiveInfinity(1.0 / 0)
false
Double.IsPositiveInfinity(1.0 / 0.0)
false
Double.IsPositiveInfinity(1 / 0.0)
true
In my experience, the usual workaround is to avoid using the debugger
for this kind of thing. Lots of people have seen problems (which may
now have been fixed) with either the immediate window or the watch
window for strings - this sounds like a similar kind of thing.

If I debug the code IsPositiveInfinity returns true wether
the divisor is int or double unlike Immediate window.

Pertti Martikainen
 
Pertti Martikainen said:
Double.IsPositiveInfinity(1.0 / 0)
false
Double.IsPositiveInfinity(1.0 / 0.0)
false
Double.IsPositiveInfinity(1 / 0.0)
true

Right. It sounds like the division bit of the immediate window isn't
quite working then.
thing.

If I debug the code IsPositiveInfinity returns true wether
the divisor is int or double unlike Immediate window.

Which is exactly what should happen, I believe.
 
Back
Top