开发者

check if value is an integer (Objective-C)

开发者 https://www.devze.com 2022-12-23 01:26 出处:网络
How do I check if my value is a integer or not? I want something 开发者_如何学Pythonlike this: if ( i/split != int ){...}

How do I check if my value is a integer or not?

I want something 开发者_如何学Pythonlike 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 or split is an integer value, ie:

if ( i % split == 0 ) {...}


Just use the objCType method? Docs

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号