views:

73

answers:

2

How can I check for a whole number in AS 3?

Example:

for (var i:int = 0; i < thumbs.length(); i++) 
{
      if((i / this.thumbsRow) === wholeNumber)
}
+3  A: 
if(int(k) === k)
  trace("whole number");
else
  trace("float");
Amarghosh
+2  A: 

Try the modulo operator:

var isWhole:Boolean = foo % 1 == 0;
trace("Is whole number: " + isWhole);

Where 'foo' is the number you're checking. Modulo gives you the remainder of dividing the first number by the second number. For any whole number, there would be no remainder.

Burnt