Forums

How to tell if a variable is Infinity or NaN (not a number)?

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

How to tell if a variable is Infinity or NaN (not a number)?

Postby JohnSchock » Fri Jun 25, 2010 10:59 am

I'm playing with the BlindWatchMaker1.cobra program that came with the installation and making some changes to the code. I need to add an if statement which checks whether a variable is either NaN or Infinity, how would I do that?
JohnSchock
 
Posts: 2

Re: How to tell if a variable is Infinity or NaN (not a numb

Postby Charles » Fri Jun 25, 2010 9:41 pm

x.isNaN and x.isInfinity

In other words, these are properties on "float" typed values. You can see all the properties and methods on primitive types at the PrimitiveTypeMembers wiki page.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: How to tell if a variable is Infinity or NaN (not a numb

Postby Charles » Fri Jun 25, 2010 9:43 pm

more directly:
if x.isNaN or x.isInfinity, trace x
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: How to tell if a variable is Infinity or NaN (not a numb

Postby Charles » Fri Jun 25, 2010 9:49 pm

One more note. You're always free to post questions here, but I just wanted to point out that if you use the wiki search for things like "infinity" you will get your answers even faster. And then, of course, it becomes interesting to find out what answers you did not get from the wiki so we (and possibly you) can expand it.

Our forums have a search as well. Unfortunately, these are two separate software packages and although we managed to integrate their user accounts, the searches are separate for now.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: How to tell if a variable is Infinity or NaN (not a numb

Postby JohnSchock » Fri Jun 25, 2010 10:11 pm

Chuck wrote:One more note. You're always free to post questions here, but I just wanted to point out that if you use the wiki search for things like "infinity" you will get your answers even faster.


Yea, I actually found the answer almost immediately after I posted :oops:
JohnSchock
 
Posts: 2


Return to Discussion

Who is online

Users browsing this forum: No registered users and 79 guests