NaN
- Started
- Last post
- 10 Responses
- Engage
In actionscript what do I use to check to see if a number is NaN or undefined etc?
- jpea0
why not just if statements or switch? if (i==undefined){ yadda yadda
- skt0
if (i==NaN) {
do something
}
else if (i==undefined) {
do something altoegthor different
}
- Engage0
didn't seem to work... so i did
if (myNumber - myNumber 0){
must be undefined
}
- skt0
I like your style of thinking.
- Engage0
removed my 'doesn't equal'
- Engage0
my brain is full of workarounds these days... wish i kept to drawin'
- UndoUndo0
you can also use
isNaN();
there's a bit about it in help
- Engage0
ta
- Fariska0
NaN usually is given as result of an operation in which between the two operator, one is not a number, and the result is obviously Not a Number (ie: when you try to add a number to a string, you (usually) perform a concatenation, not an addition)
you check this with isNan() methodundefined is when something does not exists, for me is the thirb boolean value (in addition to true and false)
useful to check variables:
if ( myVar==undefined){
myVar = myvavlue
}
- chrisRG0
if(isNaN(yourVar)){
do this is is true
} else {
do this if is false
}