在iOS应用中使用mod运算符 [英] Using mod operator in iOS app

查看:155
本文介绍了在iOS应用中使用mod运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个存储为double的NSTimeInterval。我想使用%运算符获得第二个值的分钟数。

I have an NSTimeInterval that is stored as a double. I would like to get the amount of minutes that are inide of the second value using the % operator.

minutes = secondValue % 60;

其中会议记录为双分钟

结果是XCode说二进制%的操作数无效

The result is that XCode says "Invalid operands to binary %"

想法?

推荐答案

OP改变了他们的问题,所以这是我的新答案:

The OP changed their question, so here is my new answer:

你想要do minutes = floor(secondsValue)/ 60; 你想要int除法,而不是模数。

You want to do minutes = floor(secondsValue) / 60; You want int division, not modulus.

这篇关于在iOS应用中使用mod运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆