Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

check if value is an integer (Objective-C)

How do I check if my value is a integer or not?
I want something like this:


if ( i/split != int )  {...}

Thanks,

like image 471
ludo Avatar asked Jun 24 '26 21:06

ludo


2 Answers

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 or split is an integer value, ie:

if ( i % split == 0 ) {...}
like image 132
progrmr Avatar answered Jun 28 '26 02:06

progrmr


Just use the objCType method? Docs

like image 24
Rev316 Avatar answered Jun 28 '26 02:06

Rev316