Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 09-10-2004, 01:11 PM   #1 (permalink)
Rotkiv
Code Monkey
 
Rotkiv's Avatar
 
Join Date: Apr 2004
Location: Silicon Valley, CA
Posts: 64
Rotkiv is on a distinguished road
Send a message via AIM to Rotkiv Send a message via MSN to Rotkiv
Question isnan

In javascript i remember that there was a function called isnan that determined wether the information in quetion was 'not a number.' How does one determine this in C++?
Rotkiv is offline   Reply With Quote
Old 09-10-2004, 03:53 PM   #2 (permalink)
joe_bruin
LOAD "*",8,1
 
Join Date: Feb 2003
Location: la.ca.us
Posts: 254
joe_bruin is on a distinguished road
in c, everything is a number. whether the number representation is legal or meaningful is up to the programmer to decide.
joe_bruin is offline   Reply With Quote
Old 09-10-2004, 07:13 PM   #3 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
On Unix system, you'll have the isnan method at your disposal ( math.h ). You'll need to check for both infinity as well as not-a-number. Use a logical OR. That's a caveat!

- Take the square root of a negative number.
- Check for: isnan(MyNumber) || isinf(MyNumber)

Check out this:
http://math.nist.gov/tnt/index.html

Download that tool, since the C++ standard does not yet defined functions to classify NaN's. At least you'll have something to work with.
__________________
Valmont is offline   Reply With Quote
Old 09-11-2004, 08:59 PM   #4 (permalink)
Rotkiv
Code Monkey
 
Rotkiv's Avatar
 
Join Date: Apr 2004
Location: Silicon Valley, CA
Posts: 64
Rotkiv is on a distinguished road
Send a message via AIM to Rotkiv Send a message via MSN to Rotkiv
cool, thank you very much.
Rotkiv is offline   Reply With Quote
Old 09-14-2004, 12:51 PM   #5 (permalink)
bdiamond
Registered User
 
Join Date: Jul 2004
Posts: 5
bdiamond is on a distinguished road
isn't there also a function called 'isdigit()'? that you could use on each char
bdiamond is offline   Reply With Quote
Old 09-14-2004, 08:25 PM   #6 (permalink)
frrossk
Registered User
 
frrossk's Avatar
 
Join Date: Sep 2004
Posts: 6
frrossk is on a distinguished road
Sure...isdigit(), isalpha(), etc..there are more function of this kind...check out http://msdn.microsoft.com/library/de..._.iswdigit.asp
frrossk is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 05:58 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting