Hi,
How do I check if my value is a integer or not?
I want something like this:
if ( i/split != int ) {...}
Thanks,
Hi,
How do I check if my value is a integer or not?
I want something like this:
if ( i/split != int ) {...}
Thanks,
I'm not sure but I think you're trying to find out if the result of the divide is a whole number. You can use modulus operator % to get the remainder from the divide operation.
Assuming i and split are integer types (int, long, short, etc), then modulus returns 0 when i/split is an integer value, ie:
if ( i % split == 0 ) {...}
This doesn't make sense. There shouldn't be any way to get a value you don't know the type of. Look at the variable holding the value or the function returning it and that will tell you your type. You can't have a variable that might be an int. Such a type doesn't exist in C (aside from unions, but then it's a union type). If you're trying to tell whether a float value is an integer, you can test whether the float is within a tiny value of the float's value rounded.