[英]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, 谢谢,
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: 假设
i
和split
是整数类型(int,long,short等),那么当i
或split
是整数值时,模数返回0,即:
if ( i % split == 0 ) {...}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.