This tutorial explains how to check if a number given is an integer. An integer is a number that, when divided by 1, has no remainder. In other terms, integers cannot be fractions, mixed or irrational.
This Boolean expression will return true if the number is an integer:
<([floor v] of (number)) = (number)>
This is because the "floor" function in the () of () block returns the highest integer lower or equal to the number, and if the number is already an integer, the result will be equal to the number. The "ceiling" option and the Round () block also work.
If the Variable "t" is an integer, the sprite will say "t is an integer!".
set [t_checkint v] to (t) repeat (t) change [t_checkint v] by (-1) end if <(t_checkint) = > then say [t is an integer!]
If "n" is an integer, then this boolean will be true:
<((n) mod (1)) = (0)>This works because the () Mod () (block) block tells you the exact remainder even if it isn't an integer. So
((1.2478) mod (1))
would report 0.2478, not 0.