int i = rand%10+1; if(i/3 == int) do this
Testing for Whole Numbers,
Crossbones+ - Reputation: 7022
Posted 13 August 2012 - 11:22 PM
if (i % 3 == 0) // i is divisible by 3, and thus i / 3 is an integer
Moderators - Reputation: 20747
Posted 13 August 2012 - 11:55 PM
In C, C++, C#, and Java (my best guesses from the snippet you posted) values do not change types at runtime. So if you write this code:
int foo = [some expression];
Then foo is an integer, and always will be. If you try to assign anything else to it, you either get a compiler error, or you get the integer part of whatever number you tried to assign, if you use a cast.
If you're talking about a different language, which actually does support "dynamic types" (i.e. types of variables/values can change at runtime) then you'll need to specify the language, as they all differ in how you test for a specific type.