473,799 Members | 2,988 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IsNaN

Hi,

The following lines are from my Immediate - window:

dValue
NaN
Double.IsNaN(dV alue)
false

I evaluate variable dValue, I get NaN but IsNaN returns
false. What am I doing wrong?
Best Regards
Pertti
Nov 15 '05 #1
4 9683
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.
Nov 15 '05 #2
Pertti Martikainen <no*******@kolu mbus.fi> wrote:
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


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.IsPositi veInfinity 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.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Nov 15 '05 #3
(Out of interest, what happens if you test for
Double.IsPosit iveInfinity for each of the above?)
Double.IsPositi veInfinity(1.0 / 0)
false
Double.IsPositi veInfinity(1.0 / 0.0)
false
Double.IsPositi veInfinity(1 / 0.0)
true
In my experience, the usual workaround is to avoid using the debuggerfor this kind of thing. Lots of people have seen problems (which maynow have been fixed) with either the immediate window or the watchwindow for strings - this sounds like a similar kind of thing.


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

Pertti Martikainen
Nov 15 '05 #4
Pertti Martikainen <no*******@kolu mbus.fi> wrote:
(Out of interest, what happens if you test for
Double.IsPosit iveInfinity for each of the above?)


Double.IsPositi veInfinity(1.0 / 0)
false
Double.IsPositi veInfinity(1.0 / 0.0)
false
Double.IsPositi veInfinity(1 / 0.0)
true


Right. It sounds like the division bit of the immediate window isn't
quite working then.
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 IsPositiveInfin ity returns true wether
the divisor is int or double unlike Immediate window.


Which is exactly what should happen, I believe.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
15469
by: YT | last post by:
Hello, Here's the situation: I have several fields split into 2 sections (Debt & Equity) on a form that should only take numerical values. The page is a mix of Javascript & ASP such that when the user visits the page, the initial values of the field are filled in by Session cookies. When the cursor leaves a field, the code checks to see if the entry is a number, and if it is not then it replaces it with a "0". Then it checks each field for...
13
2423
by: s_m_b | last post by:
I'm building a suite of online forms for insurance. These have been stripped down from messy MS Word templates, and two of the six, substantially identical, are misbehaving with the .js page that validates some of the content. The correct behaviour is that some fields must have content, some must have valid dates/times. On validation, the form is POSTed to a processing page that flows it into a blank template and emails that elsewhere. ...
5
15642
by: Skybuck Flying | last post by:
Hi, I have one more remaining "problem" with compiling a unix source code for windows/visual c/c++ 6.0 What does the isnan routine do ? Documentation says it checks for NaN ? What does that mean ? What is a good replacement for Visual C/C++ 6.0 ?
4
4552
by: siaj | last post by:
I am new to jscript.. I am trying to validate if a textbox on my ASP.NET page has numeric value.. The code I am using is function IsValidAmount() { var intTotalAmt = document.Form1.txtTotalAmt.value; If (isNaN(intAmt1)== false) {//do something} }
2
49866
by: Priya | last post by:
Halo. I am using isinf() & isnan() in my code, and i get an error error LNK2001: unresolved external symbol "int __cdecl isnan(double)" (?isnan@@YAHN@Z) my code is the implementation of LambertW function #include <math.h>
6
5588
by: Java script Dude | last post by:
Small glitch (IMHO) in JavaScript is related to isNaN() boolean function. If passed a null, it returns true which is incorrect. This one cause me quite a bit of grief until I detected it and was able to code around it. Anybody know the reasoning for the result being false and not true for isNaN(null). - JsD
4
4294
by: jacob navia | last post by:
Hi Has C++ defined the function isnan() for complex numbers? What is the definition? Thanks in advance -- jacob navia jacob at jacob point remcomp point fr
9
9952
by: void main | last post by:
I'm rather new to complex numbers in C and was wondering, how do I initialize a complex variable properly if the imaginary part is 0. I tried -------- #include <complex.h> float complex c = 1.0f; --------
1
2209
by: Alexio | last post by:
I have two similar function that need to be combined. Individually they both work however combined one over rides the other. The code is attached below and an attachment is included for data information. I have attached a screen shot of data <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta...
0
9686
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9540
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10475
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10222
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9068
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4139
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.