Using mod operator in iOS app
问题 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; where minutes is declared as double minutes The result is that XCode says "Invalid operands to binary %" Thoughts? 回答1: The OP changed their question, so here is my new answer: You want to do minutes = floor(secondsValue) / 60; You want int division, not modulus. 回答2: From the C standard, section 6.5.5